Ios 将文件上载到Dropbox中的特定文件夹
我有一个iphone应用程序,我想将手机本地磁盘上的文件上传到用户的dropbox。我想给用户一个选项,将其上传到dropbox中的任何位置。我见过很多应用程序都能做到这一点,但在网上还没有找到任何能让我一步一步地学习教程的例子。任何提示都会有帮助 编辑:Ios 将文件上载到Dropbox中的特定文件夹,ios,objective-c,dropbox,dropbox-api,Ios,Objective C,Dropbox,Dropbox Api,我有一个iphone应用程序,我想将手机本地磁盘上的文件上传到用户的dropbox。我想给用户一个选项,将其上传到dropbox中的任何位置。我见过很多应用程序都能做到这一点,但在网上还没有找到任何能让我一步一步地学习教程的例子。任何提示都会有帮助 编辑: //setup DBSession* dbSession = [[DBSession alloc] initWithAppKey:@"XXX"
//setup
DBSession* dbSession = [[DBSession alloc] initWithAppKey:@"XXX"
appSecret:@"XXX"
root:kDBRootDropbox];
[DBSession setSharedSession:dbSession];
[self handleDropboxSession];
DBRestClient *restclient = [[DBRestClient alloc] initWithSession:dbSession];
restclient.delegate = self;
[NSTimer scheduledTimerWithTimeInterval:5.0f block:^{
[self testSaveFileToDBox:restclient];
} repeats:NO];
//relevant methods
-(void)testSaveFileToDBox:(DBRestClient *)client
{
NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSString *filename = @"working-draft.txt";
NSString *destDir = @"/";
[client uploadFile:filename toPath:destDir
withParentRev:nil fromPath:localPath];
}
- (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath
from:(NSString*)srcPath metadata:(DBMetadata*)metadata {
NSLog(@"File uploaded successfully to path: %@", metadata.path);
}
- (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error {
NSLog(@"File upload failed with error - %@", error);
}
-(void)restClient:(DBRestClient *)client uploadProgress:(CGFloat)progress forFile:(NSString *)destPath from:(NSString *)srcPath{
NSLog(@"upload progress");
}
文件“working draft.txt”不存在,但是没有调用错误委托方法。FWIW,这一切都是应用程序内委托。最近的事情是。dropbox似乎没有提供官方的“文件夹选择器”,所以所有这些应用程序都推出了自己的自定义解决方案,就像我上面展示的一样。在您努力将文件上载到dropbox的地方显示您的相关代码。@rmaddy使用代码样本编辑,我发现这非常相似。如果你知道有更好的,告诉我!