Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi
I read the forum here, many answer to related questions point to discontinued stackoverflow documentation.
Specific question: How can I resume uploading a large file using the obj-c V2 API.
I am currently uploading as shown below.
The DBUploadTask has "cancel" and "resume" selectors. But how can these be persisted?
Should I use another upload method?
Is there any sample-code?
Thanks
Wouter
DBUploadTask *thisTask = [[[client.filesRoutes uploadUrl:remotePath mode:[[DBFILESWriteMode alloc] initWithOverwrite] autorename:@(NO) clientModified:nil mute:nil propertyGroups:nil inputUrl:localFilePath] setResponseBlock:^(DBFILESFileMetadata *result, DBFILESUploadError *routeError, DBRequestError *error) { if (result) { // finished successfully } else { id theError = routeError ? routeError : error; DebugError( @"%@", theError); } }] setProgressBlock:^(int64_t bytesDownloaded, int64_t totalBytesDownloaded, int64_t totalBytesExpectedToDownload) { DebugLog(@"\nDownloaded: %.02f KB\nTotal done: %.02f KB\nTotal expected: %02.f KB\n", (CGFloat)bytesDownloaded/1024.0f, (CGFloat)totalBytesDownloaded/1024.0f, (CGFloat)totalBytesExpectedToDownload/1024.0f); } ];
What do you mean exactly when you ask "how can these be persisted?" Once you have that DBUploadTask, you can call suspend, resume, or cancel if/when desired. You can keep that object whever you want, e.g., as a property of the controller.
[thisTask suspend]; ... [thisTask resume]; ... [thisTask cancel];
Also, note that for larger files (over 150 MB maximum), you should use upload sessions instead. When doing so, you can keep track of progress in between the individual calls.
Hi Greg,
Thanks for the reply
What do you mean exactly when you ask "how can these be persisted?" Once you have that DBUploadTask, you can call suspend, resume, or cancel if/when desired. You can keep that object whever you want, e.g., as a property of the controller.
Yes as a property, but how can a task be persisted... between session. To disk. To run again several hours later when the user next starts the app or next has network access?
Also, note that for larger files (over 150 MB maximum), you should use upload sessions instead. When doing so, you can keep track of progress in between the individual calls.
Thanks for that link: is there any sample code that uses upload sessions?
Wouter
The single upload calls, i.e., the non-upload session methods such as uploadUrl, are not meant for use over long periods of time, as they operate using only a single HTTPS request. If you need to manage an upload over a long period of time like this, upload sessions would work better. You can store the upload session's sessionId (a String) and offset (an NSNumber) however you wish. An upload session is good for up to 48 hours.
I don't have a sample implementation of using upload sessions with the Objective-C SDK unfortunately. There are some other samples that can serve as a guide in this thread though.
Thanks, that helps
Wouter
The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.
Sound good? Let's get started.Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on Twitter or Facebook.
For more info on available support options, see this article.
If you found the answer to your question, please 'like' the post to say thanks to the user!