file-upload - DropboxSDK : What's the benefit of uploadFileChunk: over uploadFile: in DBRestClient?

标签 file-upload dropbox dropbox-api

序言:

如果您觉得这可能与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_puthttps://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/

相关文章:

php - 处理多个并发的大型上传

javascript - Chrome 扩展 - 将 CSV 文件上传为 Dropbox 格式问题

ios - 多个 iOS 应用程序在生产中使用相同的 Dropbox API key ?

java - 存储 box 或 dropbox 文件

java - Android - Dropbox : Check for differences

java - GWT - 客户端文件上传

javascript - 通过调用 Web 服务从 JavaScript 上传文件

java - 如何在 JSch SFTP 上获得声誉?

dropbox - 我可以在 Dropbox V2 API 中使用文件 ID 搜索/获取文件吗?

linux - 无法通过 SSH 在远程服务器上安装 Dropbox