序言:
如果您觉得这可能与Using iOS Dropbox SDK to do a Chunked Upload of Core Data重复那么我不得不让你失望了 - 我的问题不是如何上传。相反,我的问题是比较两种上传方法的优缺点。其他问题没有涵盖这一点,所以我的问题不是重复的。
问题:
对于使用 DropboxSDK 上传文件,有两种不同的方法。评论只说一种方法“对于大于几兆字节的文件更好”。具体有哪些好处呢?第二种方法似乎比较难用,那么它有什么优点呢?
以下是 iOS DropboxSDK 中的两种方法:
1.
上传文件:
/* 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;
最佳答案
参见https://www.dropbox.com/developers/core/docs#files_put和 https://www.dropbox.com/developers/core/docs#chunked-upload .
前者允许最多 150MB 并在单个 HTTP 请求中写入文件,因此如果不从文件开头重新开始,就无法恢复失败的上传。
后者允许任何大小,并且任何失败的上传都可以从中断处恢复(只需发送下一个 block )。
关于file-upload - DropboxSDK : What's the benefit of uploadFileChunk: over uploadFile: in DBRestClient?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23323108/