1

我为我的应用程序添加了 Dropbox 支持,一切正常,身份验证,登录/退出,但我无法上传文件。我在用

NSArray *p = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString* docDir = [p objectAtIndex:0];
    NSString *localPath = docDir;
    NSString *filename = @"Documents";
    NSString *destDir = @"/";
    [[self restClient] uploadFile:filename toPath:destDir
                    withParentRev:nil fromPath:localPath];

将我的应用程序 /Document 目录上传到 Dropbox,但没有上传任何内容。我没有收到任何错误消息。目录 Apps/My-Applications-Name 已创建,但其中没有内容。

有谁知道为什么?

我也有这两个委托方法,但我仍然没有得到日志。我也有<DBRestClientDelegate>后面的@interface … ()

- (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);

}
4

4 回答 4

0

听起来像是Documents一个目录,但uploadFile用来上传文件。我认为 Core API 中没有上传文件夹内容的方法,因此您必须浏览文件夹并单独上传每个文件。

于 2013-08-30T19:56:10.947 回答
0
NSArray *p = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString* documentDirectory = [p objectAtIndex:0];
    NSString *filename = @"png.png";
    NSString *destDir = @"/";
    [[self restClient] uploadFile:filename
                           toPath:destDir
                    withParentRev:nil
             fromPath:[documentDirectory stringByAppendingPathComponent:filename] ];

“fromPath”必须是源文件的完整路径。API 文档错误。

于 2014-02-05T06:46:48.000 回答
0

您是否实现了 Dropbox 委托方法?Uploadcompleted和uploadfailedwitherror?您还需要在您的应用委托中指定您是 Dropbox 委托,以便实现这些方法。确保你的本地路径是正确的,你的上传路径是正确的。

将 DBRESTClientDelegate 添加到您的应用程序委托或任何类上传

于 2013-08-31T16:09:16.063 回答
-1

Did you check that you're making setting the delegate from the main thread? Otherwise, your thread likely doesn't have a runloop and the delegate callbacks will never be called.

UPDATE my problem was ARC destroying the DBRestClient object before the upload was complete.

于 2015-06-17T08:49:20.980 回答