将文件上传到Dropbox中的特定文件夹

时间:2014-02-18 01:45:26

标签: ios objective-c dropbox dropbox-api

我有一个iphone应用程序,我想将手机本地磁盘上的文件上传到用户的保管箱。我想让用户选择将其上传到他的Dropbox中的任何位置。我见过很多应用程序这样做,但没有找到任何在线的例子,它带我一步一步的教程。任何指针都会有所帮助!

编辑:

//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,这一切都在应用代表中。

1 个答案:

答案 0 :(得分:1)

最近的事情是https://github.com/goosoftware/GSDropboxActivity。似乎dropbox没有提供官方的“文件夹选择器”,因此所有这些应用程序都推出了自己的自定义解决方案,就像我上面展示的那样。