cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: File upload to dropbox timeout/pauses after certain time. Objective c SDK for dropbox.

File upload to dropbox timeout/pauses after certain time. Objective c SDK for dropbox.

SneYellow46
Explorer | Level 4

Hi,

We have an iOS objective c app with dropbox sdk integrated.

The app uploads large number of photos/files from local app storage to dropbox folder.

When we start the upload process it uploads almost 40-45 images/files for example and pauses the upload process after certain time.

We need to close the app and relaunch the app again so that the upload process starts again syncs the remaining files to the dropbox.

We are using following upload code specified in the dropbox documentation.

 

 

 

 

 

NSData *fileData = [@"file data example" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];

// For overriding on upload
DBFILESWriteMode *mode = [[DBFILESWriteMode alloc] initWithOverwrite];

[[[client.filesRoutes uploadData:@"/test/path/in/Dropbox/account/my_output.txt"
                            mode:mode
                      autorename:@(YES)
                  clientModified:nil
                            mute:@(NO)
                  propertyGroups:nil
                       inputData:fileData]
    setResponseBlock:^(DBFILESFileMetadata *result, DBFILESUploadError *routeError, DBRequestError *networkError) {
      if (result) {
        NSLog(@"%@\n", result);
      } else {
        NSLog(@"%@\n%@\n", routeError, networkError);
      }
    }] setProgressBlock:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedToUploaded) {
  NSLog(@"\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded);
}];

 

 

 

 

 

 

Can you please let us know what could be the issues and is there any fix for this. 

 

10 Replies 10

Greg-DB
Dropbox Staff

Can you clarify what happens when it "pauses the upload process after certain time"? For instance, do you get any error/output?

 

Also when you say you upload a "large number of photos/files", how many are you uploading simultaneously?

SneYellow46
Explorer | Level 4

@Greg-DB , we have a system where in we upload almost 100-150 images/files at a time. 

With regards to error message, we sometimes get upload timeout from dropbox and sometimes it just pauses without going to error block.

So not really sure what is causing the issue. dropbox sdk has mentioned in the documentation that iOS wont stop the upload/download process and there is no timeout. 

Greg-DB
Dropbox Staff

Uploading 100-150 files at the same may exhaust the system or network connection, as each one requires its own HTTPS request. I recommend limiting how many you perform simultaneously. You may want to experiment a bit to see what a good limit is for your scenario/environment.

SneYellow46
Explorer | Level 4

Hi @Greg-DB , I tested the app several times.

As per my investigation the issue is it goes into error block for few upload requires(out of all) with timeout error when trying to upload so many files in a loop at once.

Is there any solution provide by Dropbox SDK for this other than limiting the number of files/requests to upload at a time?

Let me know soon.

Thanks,

Greg-DB
Dropbox Staff

The Dropbox Objective-C SDK does offer a 'batchUploadFiles' method that you may want to use instead: https://github.com/dropbox/dropbox-sdk-obj-c#upload-style-request

Здравко
Legendary | Level 20

Hi @SneYellow46,

Key moment, when multiple uploads are performing simultaneous, is high probability different uploads to stuck on catching GIL (leading to issues). You can decrease such probability as make upload itself and attach file to the folder tree (only the attach actually needs GIL catch) in 2 different steps, so many uploads can happen simultaneous without risk for conflict and finalization of all files can happen at once. 😉

Hope this helps.

SneYellow46
Explorer | Level 4

Hi @Greg-DB , I tried the Batch method before and it still goes to timeout.

 

@Здравко , thanks for the advise but this approach isn't feasible for our scenario.

 

I guess we need to handle this from our end with our own logic.

Здравко
Legendary | Level 20

@SneYellow46 wrote:

..., thanks for the advise but this approach isn't feasible for our scenario. ...


🤔🤷 Why? 🧐

 


@SneYellow46 wrote:

...

I guess we need to handle this from our end with our own logic.


What kind of logic is in use currently and is something prevent it to be used further?

 

Every upload is performed on 2 steps (as I mentioned) - actual upload and attach to directory tree. The way you are using performs both steps at once. This is convenient for single (or few) upload. For many (and/or big) files alternatives can be useful. In all cases upload is performed in the same way, just different way of organizing.

SneYellow46
Explorer | Level 4

@Здравко , So how should be the upload code for iOS objective c to dropbox api?

currently I am using the above in loop for multiple files.

We need files(not as another folder) to be uploaded in a specific folder in dropbox. These files are processed by another application from there.

Need more support?