Create a folder in dropbox from Iphone App

2019-02-16 02:59发布

问题:

I am a beginner in iOS development and have just started using the DropBox SDK for iOS. I am using XCode 3.2.5 having the simulator 4.2 . I wanted to create a folder(or directory) on my dropbox account using the DropBox SDK programmatically and upload files directly to that folder in my DropBox account. I have the following code to upload a file

[[self restClient] uploadFile:@"info.txt" toPath:@"/" withParentRev:nil fromPath:sourceString];

I have to store this file inside a folder called TempData(suppose). Then, I tried doing the following

[[self restClient] uploadFile:@"info.txt" toPath:@"/TempData/" withParentRev:nil fromPath:sourceString];

but, it uploaded the file in the default directory for my App. Also, can I upload the contents of an entire directory in to my dropbox account. I have a lot of metadata files which need to be uploaded along with the uploaded files. So, is there a way to upload the entire contents of a folder to dropbox. I have looked up the API in DropBox SDK version 1.1 for iOS, but, it does not have any facility to upload an a directory or all of its contents recursively. So, Will I have to traverse recursively over the contents of a directory and send multiple requests? Please help

回答1:

This is used to create a Folder in DropBox

[[self restClient] createFolder:@"/YourFolder"];

This is Used to get details of the newly created folder

// Folder is the metadata for the newly created folder
- (void)restClient:(DBRestClient*)client createdFolder:(DBMetadata*)folder{
    NSLog(@"Created Folder Path %@",folder.path);
        NSLog(@"Created Folder name %@",folder.filename);
}
// [error userInfo] contains the root and path
- (void)restClient:(DBRestClient*)client createFolderFailedWithError:(NSError*)error{
    NSLog(@"%@",error);
}