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: 

Dropbox API to create a file, write in it via stream and then close the file.

Dropbox API to create a file, write in it via stream and then close the file.

Priya M.
Explorer | Level 4

Hi,

 

I am from Softaculous Ltd. I already have an open issue but here I'm opening a new one which is regarding a different issue.

 

I have a query regarding Dropbox. We want our users to upload their backups (which will be .tar.gz file) on Dropbox. Now what we want is that we can create an empty file on Dropbox, add the content to it via stream (as in we can do via FTP using ftp:// stream) and then close the file.

 

I'm not able to find the related APIs. Can you please tell me about it?

21 Replies 21

Priya M.
Explorer | Level 4
Hi,

Also I'm trying to upload a .tar.gz file but the file is uploaded incompletely and corrupted using upload session functionality. Can you tell me the reason?

Greg-DB
Dropbox Staff

1. I'm not sure I follow. Exactly what functions are called and when is controlled by your app. You may want to step through with a debugger to see what it is doing and how to correct it.

 

2. You don't have to upload the same amount of data with each call. For example, when you only have less than 1 MB left to upload, you can call finish and upload that less than 1 MB amount of data.

 

When using upload sessions, you should only call start once per file. Then you can call append as many times as necessary. You should then call finish once. You don't have to send the same amount of data in each call (e.g., the last call will usually contain less than the others) but you do need to upload the file data in order.

 

If you're not getting valid files, you should debug your implementation to make sure you're sending up all of the correct data, and in order. (From your earlier post, it sounds like you're missing the last piece.)

Priya M.
Explorer | Level 4

Hi,

 

Thank you for your response. I was able to find the reason for the behavior I had been thinking as unexpected.

 

But while debugging I'm facing issue with curl call. Many timess the curl call fails with the error "Curl Error Start: Empty reply from server (Server returned nothing no headers no data)". Sometimes upload session start returns this error and sometimes append. I'm not able to understand why this is happening.

 

Can you please tell me why?

Priya M.
Explorer | Level 4

Hi,

 

And sometimes it return this:

Failed sending data to the peer

Greg-DB
Dropbox Staff
Both of these errors are unexpected. Can you share the steps/code to reproduce them?

They may be network issues though, which likely won't reproduce for me though. If that's the case, you'll want to check on any issues with your network connection, and add automatic retrying to your app.

Priya M.
Explorer | Level 4

Hi,

 

I am able to do everything now. Upload the file in sessions.

 

I have another problem now. That it is taking too much time. Uploading data in chunks, we require to make curl call in every chunk and our file sizes can be in GBs. Therefore, its taking toooo much of time.

 

Is there some solution to this?

Greg-DB
Dropbox Staff
Your connection speed to Dropbox depends on the routing you get between your ISP and our servers, and may be slower than your ISP's rated speeds.

Sometimes resetting or retrying your connection gets you a different route and better speeds, but that is outside of our control. Some ISPs also throttle sustained connections so if you see an initial high connection speed followed by lower speeds, that could be the reason.

The chunk size you use will also affect your overall transfer rate though. Smaller chunk sizes will be more robust and less prone to fail, but will be slower overall. Larger chunk sizes will generally be faster overall, as there will be fewer calls and therefore less overhead, but you'd need to re-upload more if any one call fails.

I recommend trying an 8 MB chunk size. The optimal chunk size will depend on various factors though, so you may want to try a few different sizes. Note that you may see some improvement by only using chunk sizes of an example multiple of 4 MB. (This is just due to specifics of how the backend in implemented. There are other factors though, so that improvement may or may not be noticeable.)

Priya M.
Explorer | Level 4

Hi,

 

Thank you for your reply. I am able to speed up the process by taking 4MB chunksize.

 

Thank you for your support.

kmeri
Explorer | Level 3

where can i get sample for write via stream

FernandoBrandao
Explorer | Level 3
Hi Priya, can you share the code with me. I have to do the same and we can share the work together. Can i know more from you? Please, my e-mail is fbrandao7 from gmail. Thanks
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Rob P.3 Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    FernandoBrandao Explorer | Level 3
  • User avatar
    kmeri Explorer | Level 3
  • User avatar
    Priya M. Explorer | Level 4
What do Dropbox user levels mean?