cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

[Obj-C V2] How to resume uploading a large file

Explorer | Level 4

 

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 4
Highlighted

Re: [Obj-C V2] How to resume uploading a large file

Dropboxer
Dropboxer

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.

Highlighted

Re: [Obj-C V2] How to resume uploading a large file

Explorer | 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

 

Highlighted

Re: [Obj-C V2] How to resume uploading a large file

Dropboxer
Dropboxer

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.

Highlighted

Re: [Obj-C V2] How to resume uploading a large file

Explorer | Level 4

Thanks, that helps

Wouter

Work Smarter with Dropbox

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.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?