0

我正在使用 DropboxSDK(核心 API)。我使用此功能上传文件:

- (void)uploadFile {

    [[self restClient] loadMetadata:@"/MyFolder"];
}

- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata {

    if (metadata.isDirectory) {
        if (metadata.contents.count == 0) {
            NSString *filename = @"File.txt";
            NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString *documentsDir = [documentPaths objectAtIndex:0];
            NSString *databasePath = [documentsDir stringByAppendingPathComponent:filename];
            NSString *destDir = @"/MyFolder";
            [[self restClient] uploadFile:filename toPath:destDir withParentRev:nil fromPath:databasePath];
        } else {
            for (DBMetadata *file in metadata.contents) {
                [self overwriteFile:metadata];
            }
        }
    }
}

我尝试使用此功能覆盖文件“File.txt”,但它不起作用。

- (void)overwriteFile:(DBMetadata*)meta {

    NSString *filename = @"File.txt";
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    NSString *databasePath = [documentsDir stringByAppendingPathComponent:filename];
    [[self restClient] uploadFile:filename toPath:meta.path withParentRev:meta.rev fromPath:databasePath];
}

调用这个代表:

- (void)restClient:(DBRestClient *)client uploadedFile:(NSString *)destPath from:(NSString *)srcPath metadata:(DBMetadata *)metadata {

    NSLog(@"File uploaded successfully to path: %@", metadata.path);
}

我在日志中显示:文件成功上传到路径:/myfolder/File.txt。然后我去 Dropbox,我看到,我的文件日期没有改变。

我做错了什么?你能帮助我吗?

4

1 回答 1

0

请注意,uploadFile上传到名为pathfilename的文件。在我看来,您可能正在尝试上传到类似. 确保是您要写入文件的文件夹。 toPath/MyFolder/File.txt/File.txttoPathFile.txt

于 2014-03-06T19:58:34.327 回答