Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Wouter V.
8 years agoExplorer | Level 4
[Obj-C V2] How to resume uploading a large file
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);
}
];
4 Replies
- Greg-DB8 years ago
Dropbox Community Moderator
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.
- Wouter V.8 years agoExplorer | Level 4
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
- Greg-DB8 years ago
Dropbox Community Moderator
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.
- Wouter V.8 years agoExplorer | Level 4
Thanks, that helps
Wouter
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!