DropboxSDK:上传文件块的好处是:上传文件:在RestClient中?

时间:2014-04-27 11:58:20

标签: file-upload dropbox dropbox-api

序言

如果您认为这可能与Using iOS Dropbox SDK to do a Chunked Upload of Core Data重复,那么我不得不让您失望 - 我的问题不在于如何进行上传。相反,我的问题是比较两种上传方法的优缺点。其他问题没有涉及,所以我的问题不重复。

问题:

对于使用DropboxSDK上传文件,有两种方法可用于两种不同的方法。评论只说一种方法更适合大于几兆字节的文件"。有什么具体的好处?第二种方法似乎更难以使用,它提供了哪些优势?

以下是iOS DropboxSDK中的两种方法:

1。 uploadFile:

/* Uploads a file that will be named filename to the given path on the server. sourcePath is the`
   full path of the file you want to upload. If you are modifying a file, parentRev represents the
   rev of the file before you modified it as returned from the server. If you are uploading a new
   file set parentRev to nil. */
- (void)uploadFile:(NSString *)filename toPath:(NSString *)path withParentRev:(NSString *)parentRev
    fromPath:(NSString *)sourcePath;

2。 uploadFileChunk:

/* These calls allow you to upload files in chunks, which is better for file larger than a few megabytes.
   You can append bytes to the file using -[DBRestClient uploadFileChunk:offset:uploadId:] and then call
   -[DBRestClient uploadFile:toPath:withParentRev:fromUploadId:] to turn the bytes appended at that uploadId
   into an actual file in the user's Dropbox.
   Use a nil uploadId to start uploading a new file. */
- (void)uploadFileChunk:(NSString *)uploadId offset:(unsigned long long)offset fromPath:(NSString *)localPath;

1 个答案:

答案 0 :(得分:2)

请参阅https://www.dropbox.com/developers/core/docs#files_puthttps://www.dropbox.com/developers/core/docs#chunked-upload

前者允许最多150MB并将文件写入单个HTTP请求中,因此无法在不从文件开头重新开始的情况下恢复失败的上载。

后者允许任何大小,任何失败的上传都可以在中断的地方恢复(只需发送下一个块)。