Dropbox SDK bug - ios

I was found something strange when I using Dropbox SDK 1.3.14
And here is how the bug happen , I put a dictionary tree like
/Comic/Author - Comic name (ex.浦澤直樹 - Monster)/Volume1/0.jpg , 1.jpg , ...)
And I want download the jpg to iOS app,And also create the same dictionary tree as Dropbox
So I create a dictionary tree in Document , It looks like
/var/mobile/Containers/Data/Application/12711FE6...290C7EAF50/Documents/Dropbox/Comic/浦澤直樹 - Monster/Volume1
Than I try to download the first page of comic
But it shows an error tell me the dictionary is not exist .
I use NSFileManager to check , It did exist .
Finally I find the problem
At this callback
- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata {
for (DBMetadata *file in metadata.contents) {
NSLog(#"File Path : %#",file.path);
}
}
Path will print like this
1./Comic
2./Comic/浦澤直樹 - Monster
3./Comic/浦澤直樹 - Monster/Volume1
4./Comic/浦澤直樹 - monster/Volume1/0.jpg
Now at the last file path , it gives me a different path name
I don't know why , but if I use this path to check is the parent dictionary is ready , It will return false.
So I never can download the file to specified path success
I was wonder does anyone got same issue like me ?

Dropbox itself is case-insensitive, with attempts to be case-preserving. However, due to various specifics, the API can't always return the expected case for every path component. So, for any file or folder metadata, the filename/last path component should have the preserved case, but other path components are not guaranteed to.
We realize this is non-ideal of course and are looking into ways to improve it, but I don't have a solution to offer right now.
If you need the preserved casing, you'll need to build it up from the last component in each parent entry.

Related

Play downloaded Widevine Classic files from app document folder in iOS?

I am trying to play wvm files from the app documents folder since 3 days but without success...
I removed "file://" from my path but I still get 1013 error (as discussed here), does someone have some sample code or at least the procedure to follow to make it works properly?
WV_RegisterAsset(myFilePath) always return WViOsApiStatus(rawValue: 1013)
The file should exists because when I try this:
let fileManager = NSFileManager()
print(fileManager.fileExistsAtPath(myFilePath))
It returns true
Thanks in advance for your help!
Widevine Classic on iOS uses an "asset root" directory. When you initialize the library, you pass it in the settings dictionary using the key WVAssetRootKey.
After that, all local asset pathnames you pass to the library are relative to the AssetRoot.
One simple option is to use NSHomeDirectory() as the AssetRoot, and then trim it from the beginning of absolute pathnames.

Steps to get the list of pdf files from FTP in IOS

I'm new to IOS Development. This is the first time i'm hearing about FTP in IOS .I'm not getting, How to proceed further . I got this code https://developer.apple.com/library/ios/samplecode/SimpleFTPSample/Introduction/Intro.html .
But i didn't understand from this code .
I need to list the pdf files and folders from FTP . First i don't know how to establish the connection to FTP . Can any one please help me with steps.
I fyou look in ListController.m, listOrCancelAction is called when you click on List button.
In turn if you put a break point in startReceive you would see that
CFReadStreamCreateWithFTPURL is opening a "Open a CFFTPStream for the URL" with a specified URL.
I suggest you put a couple more break points and step through the code?
NSStreamDelegate is being used as callbacks when something is happening in particular
- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
is called when connection is open or data is received.
Hope this is enough to get you started.
entryToAdd = [self entryByReencodingNameInEntry:(__bridge NSDictionary *) thisEntry encoding:NSUTF8StringEncoding];
in parseListData will have file name in kCFFTPResourceName which of course you can parse to find out if it is a PDF file. You may look at kCFFTPResourceType to see if you can use to determine file type, not sure.

Xamarin.Mobile Component multiple file saved getting deleted without calling delete function for iOS

We are using Xamarin.Mobile component for taking and storing photos in an local app directory. Now, its works fine when I am storing a single photo but if I am storing multiple photo and trying to access those, only last image exist, all other images are getting deleted. I don’t call delete function anywhere in my code.
We are making app for both iOS and android and we have some Core Class that are linked in both projects
When it enter the function as shown is the last call stack, only last image exists, all other image are getting deleted.
The top three functions are from our Core Class which are linked in both iOS and Android.
I have enable iTunes file sharing, images are getting stored inside Documents folder and I am giving each image a different name.
here is the code for taking photos:
Random rand1 = new Random((int) DateTime.Now.Ticks & 0x0000FFFF);
picker = new MediaPicker();
if( !picker.IsCameraAvailable )
return;
MediaPickerController controller = picker.GetTakePhotoUI (new StoreCameraMediaOptions {
Name = "Ticket"+rand1.Next(1, 1000000)+".jpg",
Directory = ""
});
this.PresentViewController( controller, true, null );
controller.GetResultAsync().ContinueWith (t => {
// We need to dismiss the controller ourselves
this.PresentedViewController.DismissViewController (true, () => {
// User canceled or something went wrong
if (t.IsCanceled || t.IsFaulted)
return;
// We get back a MediaFile
MediaFile media = t.Result;
ticket.imagePaths.Add( media.Path );
});
}, uiScheduler);
Here is my Application Output:
2014-01-15 15:17:40.445 CCR_Ticket_System_iOS[2063:60b] File Exists in TicketRepo: /private/var/mobile/Applications/ABE44A50-7119-4BF9-8DF9-DC50C80E7591/Documents/Ticket235666.jpg
2014-01-15 15:17:42.384 CCR_Ticket_System_iOS[2063:60b] File Exists in TicketRepo: /private/var/mobile/Applications/ABE44A50-7119-4BF9-8DF9-DC50C80E7591/Documents/Ticket952511.jpg
2014-01-15 15:17:49.320 CCR_Ticket_System_iOS[2063:60b] File doesn't Exists in SaveTicket in DatabaseADO: /private/var/mobile/Applications/ABE44A50-7119-4BF9-8DF9-DC50C80E7591/Documents/Ticket235666.jpg
2014-01-15 15:17:49.323 CCR_Ticket_System_iOS[2063:60b] File Exists in SaveTicket in DatabaseADO: /private/var/mobile/Applications/ABE44A50-7119-4BF9-8DF9-DC50C80E7591/Documents/Ticket952511.jpg
Please let me know what I am doing wrong. Please let me know if you need more information. I am stuck on this problem for last 2 days.
I just ran into this problem myself and saw that there was no solution posted yet. Here is what I figured out:
The problem has to do with the MediaPicker. When mediaPicker.PickPhotoAsync(), mediaPicker.TakePhotoAsync(), etc is called, it returns an object of type MediaFile. This MediaFile has a property called “Path” which contains a string with the path to the file. We store this string to use later.
The problem comes up when we realize how MediaPicker is implemented. As soon as the MediaFile is disposed of, it deletes the file that the MediaFile is associated with. Since we let the MediaPicker fall out of scope, the file gets deleted immediately after it is added to the list.
There are a couple solutions to this:
1) Keep a reference to the MediaFile until the file is no longer needed.
2) Copy the image to a new location so the MediaFile can be disposed of
Personally I think option 1 is a much better solution.

iOS dropbox SDK loading thumbnails and number of files inside a folder

Hi all I am developing an application that brings up the entire folder and file structure from any content management system for now I have done Box and sharepoint integration. I am looking to sync dropbox now. In the DBMetaData class I have properties
BOOL thumbnailExists;
NSArray* contents;
NSString* icon;
First thing I want to do here is that I want to load thumbnails of files, I do not get one thing the icon property returns a string, like this 'page_white_acrobat' (I thought it would return a url or something where I could download the thubmnail). Is there any way to bring thumbnails using the dropbox sdk. Also I uploaded a .mp4 file and .png file, they show up thumbnails when I open dropbox in chrome but in the SDK the thumbnailExists property returns NO.
Second I want the number of sub folders and the files for a folder, I tried accessing the contents property of a folder DBMetaData Object and it returned nil. Is there any way in the SDK to count the number of files inside a folder or any work around.
It seems that Dropbox just provides the name of the icon they use. You can't download it, so you should check this string and use resources in your app bundle.
The contents of a DBMetadata object will be null until you actually make a request to load metadata at that path.
This code will get you started with subdirectories.
-(void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata
{
// LOAD METADATA OF SUBDIRECTORIES
for (DBMetadata *node in metadata.contents) {
if (node.isDirectory) {
[_restClient loadMetadata: node.path];
}
}
// GET COUNT OF DIRECTORY CONTENTS
if (metadata.isDirectory) {
NSLog(#"%# contains %d files and folders", metadata.path, metadata.contents.count);
}
}
To list the contents of a path or directory, you need to call the following method of your DBRestClient object:
- (void)loadMetadata:(NSString*)path;
which then invokes the following delegate callback(please see the method body for code to download the thumbnail for each file in the listed directory):
- (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata
{
for (DBMetadata *file in metadata.contents)
{
// 1. Use the DBMetadata * file object to do things like: add a table-view cell for the file.
[self.filesListView addCellForFile: file];
// 2. Request thumbnail for each file
NSString *localThumbnailPath = [self localThumbnailPathForFile: file]; // create a local-file-path for the thumbnail
[dbRestClient loadThumbnail: file.path ofSize:#"l" intoPath:localThumbnailPath];
}
}
In the method above, the loadThumbnail:ofSize:intoPath: method will result in invoking the following delegate callback:
- (void)restClient:(DBRestClient*)client loadedThumbnail:(NSString*)localPath
from which, you must use the given localPath to update your UI with the downloaded thumbnail.

CocoaHTTPServer on iOS: set up server so user can download NSData as file

I want to make the following webpage using CocoaHTTPServer: there should be a link to download a file, but the source file must be NSData object in memory.
As far as I see in samples, there is an easy way to link some file on iPhone to the hyperlink. Is it possible to "link" NSData?
Would be very thankful for examples.
All you need to do is to return HTTPDataResponse in your HTTPConnection subclass.
If you want an example have a look at the CocoaHTTPServer sample called DynamicServer and replace - httpResponseForMethod: URI: in MyHTTPConnection with something similar to the following:
- (NSObject<HTTPResponse> *)httpResponseForMethod:(NSString *)method URI:(NSString *)path
{
// Before returning you can analyze the passed path argument and select the correct data object to return...
return [[HTTPDataResponse alloc] initWithData:placeYourDataInstanceHere];
}

Resources