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: 

batchUpload - I want to upload one file to 3 or 4 dropbox paths.

batchUpload - I want to upload one file to 3 or 4 dropbox paths.

Tom A.5
New member | Level 2
Go to solution

We need to hopefully efficently upload about a single local file into about 3 - 4 locations on a users dropbox. 

 

I am using the objective-c api, but this question is not api version specific.

 

What is the best way to do this?

There is a call that takes a dictionary of localFile paths and some fileCommitInfos, but there is a one to one mapping so I can't upload the same file to two or 3 different locations on a dropbox account. 

 

So I am thinking I upload all the files to one of the locations, then do a bunch of copies from one dropboxPath to another dropboxPath, but it seems clumsy. 

 

What I would like to do is do a batch of uploads, then commit each upload to multiple dropbox paths. 

1 Accepted Solution

Accepted Solutions

chirstius
Dropbox Staff
Go to solution

Hello @Tom A.5,

 

There may be a few options for this. Some things for you to try:

https://www.dropbox.com/developers/documentation/http/documentation#files-copy_batch

Will allow the upload once, copy-many process to possibly be consolidated to fewer calls.

 

https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-get

https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-save

Might be interesting to look at especially if you need to replicate the content between more than one user/account. You could upload once, and then replicate across accounts without having to upload again, all replication happens on the Dropbox side so it's pretty efficient.

 

Another option is the upload session mechanism:
https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start

https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2

https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batc...

https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batc...

 

But if I am reading your post correctly - this isn't about one file stored in many places, it's about many files stored in many places (though the same "set" of files repllicated in all areas) - is that correct?

 

If so, then even with upload sessions, you'd need to upload every file to every location before doing the finish batch calls. So if you are talking data efficiency (I assume this is a mobile device?) then upload once, and copy (via whatever method you think works best) might be the best option, despite requiring multiple API calls.

 

Let me know if I am interpreting your question correctly and if any of these options might fit.

 

Thanks,

 

-Chuck

View solution in original post

5 Replies 5

chirstius
Dropbox Staff
Go to solution

Hello @Tom A.5,

 

There may be a few options for this. Some things for you to try:

https://www.dropbox.com/developers/documentation/http/documentation#files-copy_batch

Will allow the upload once, copy-many process to possibly be consolidated to fewer calls.

 

https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-get

https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-save

Might be interesting to look at especially if you need to replicate the content between more than one user/account. You could upload once, and then replicate across accounts without having to upload again, all replication happens on the Dropbox side so it's pretty efficient.

 

Another option is the upload session mechanism:
https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start

https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2

https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batc...

https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batc...

 

But if I am reading your post correctly - this isn't about one file stored in many places, it's about many files stored in many places (though the same "set" of files repllicated in all areas) - is that correct?

 

If so, then even with upload sessions, you'd need to upload every file to every location before doing the finish batch calls. So if you are talking data efficiency (I assume this is a mobile device?) then upload once, and copy (via whatever method you think works best) might be the best option, despite requiring multiple API calls.

 

Let me know if I am interpreting your question correctly and if any of these options might fit.

 

Thanks,

 

-Chuck

Tom A.5
New member | Level 2
Go to solution

Thanks for the quick reply!

 

You have it right - what we are doing is uploading about 3 - 20 files into one user's account, with each file going to 4 places. So I am using batch upload already to get the files up, then I am going to make a list of instructions to use the files-copy_batch call to make the 3 copy calls (since the file is up there on the user account). There may be a small window of time (<1sec it seems) where the user could erase the originally uploaded file. Don't think that's going to happen much. Its on MacOS. It's making thousands of files (archival PDF files) in the user's dropbox account. 

 

I wish that the DBFILESCommitInfo object had a way to pass in an array of paths to copy to, instead of one file... 

 

--Tom

Greg-DB
Dropbox Staff
Go to solution
Thanks! I'll pass this along as a feature request for that DBFILESCommitInfo in the Objective-C SDK.

Tom A.5
New member | Level 2
Go to solution

https://www.dropboxforum.com/t5/API-Support-Feedback/copy-batch/td-p/211624

 

So I am running into the same bug as the one above. 

 

I call   dCopyBatch

 

Then I call to get the status of the copy with dCopyBatchCheck and I get:

 

I have the source from_path repeated and then 

 

Printing description of self->_uploadCopyBatchInfos:

 

 

<

__NSArrayM 0x6040006b3e50>(

{

    "from_path" = "/FOLDER_1/Chicopee.jpg";

    "to_path" = "/FOLDER_2/Chicopee.jpg";

},

{

    "from_path" = "/FOLDER_1/Chicopee.jpg";

    "to_path" = "/FOLDER_3/Chicopee.jpg";

},

}

And I get back "duplicated_or_nested_paths

 

The source IS duplicated, but that should be OK as I am copying files.

Greg-DB
Dropbox Staff
Go to solution
Thanks! I'll follow up on that thread.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Tom A.5 New member | Level 2
  • User avatar
    chirstius Dropbox Staff
What do Dropbox user levels mean?