我正在尝试从iOS应用中的dropbox下载图片。我收到的错误如下:
[警告] DropboxSDK:向/1/files/dropboxeditimagemarvel.png发出错误请求 - (400)预期' root'要成为' dropbox',' sandbox'或者'自动',得到你的' dropboxeditimagemarvel.png'
在AppDelegate.m中:
DBSession* dbSession =
[[DBSession alloc]
initWithAppKey:@"23a9qum6roclx38" // add here app key
appSecret:@"nh04ru3g53kgzat" // add here app secret key
root:kDBRootDropbox];// either kDBRootAppFolder or kDBRootDropbox
[DBSession setSharedSession:dbSession];
在UIViewController.m中
[restClient loadMetadata:@"/"];
- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata
{
if (metadata.isDirectory)
{
NSArray *validExtensions = [NSArray arrayWithObjects:@"jpg", @"jpeg", @"png", nil];
NSLog(@"Folder '%@' contains:", metadata.path);
for (DBMetadata *file in metadata.contents) {
NSLog(@"%@", file.filename);
NSString* extension = [[file.path pathExtension] lowercaseString];
if(![file isDirectory] && [validExtensions indexOfObject:extension]!=NSNotFound) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents directory
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[@"/dropbox/" stringByAppendingString:@"example.png"]];
NSError *error;
[restClient loadFile:file.filename intoPath:filePath];
}
}
}
}
- (void)restClient:(DBRestClient *)client
loadMetadataFailedWithError:(NSError *)error {
NSLog(@"Error loading metadata: %@", error);
}
- (void)restClient:(DBRestClient *)client loadedFile:(NSString *)localPath
contentType:(NSString *)contentType metadata:(DBMetadata *)metadata {
NSLog(@"File loaded into path: %@", localPath);
}
请帮助我......谢谢。