Question

Preamble:

In case you feel that this might be a duplicate of Using iOS Dropbox SDK to do a Chunked Upload of Core Data then I have to disappoint you - my question is not about how to do the upload. Instead, my question is about comparing the pros and cons of two approaches for uploading. That's not covered by the other question, so my question is not a duplicate.

Question:

For uploading a file with the DropboxSDK, there are two methods for two different approaches. The comments only say that one method is "better for file larger than a few megabytes". What are the concrete benefits? The second approach seems to be more difficult to use, so what advantages does it provide?

Here are the two methods as found in the 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;
Was it helpful?

Solution

See https://www.dropbox.com/developers/core/docs#files_put and https://www.dropbox.com/developers/core/docs#chunked-upload.

The former allows for up to 150MB and writes the file in a single HTTP request, so there's no way to resume a failed upload without starting over from the beginning of the file.

The latter allows any size, and any failed upload can be resumed where it left off (by just sending the next chunk).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top