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

Discuss Dropbox Developer & API

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

is there a way we can resume downloads from where it left ?

Explorer | Level 4

Hi Guys, 

I wrote code using dropbox java sdk to download all the files in dropbox to my NAS (Network-attached storage). The data is huge . I tried to make the process faster using thread pool executor. However, when I abruptly close the program or when a fatal error occurus it corrupts the files that were in progress. Is there a way that we can delete the files that were not fully copied at the time of the fatal error? 

below is the draft code .. a lot of improvements can be made to it. 

https://github.com/sukanth/Dropbox

1 Accepted Solution

Accepted Solutions
Highlighted

Re: is there a way we can resume downloads from where it left ?

Dropboxer
Dropboxer

Yes, it looks like in that case you've only written a portion of the file, so you could check how much of the file you did write, and then use DbxDownloadStyleBuilder.range to download just the rest of the file.

Also, if it's helpful, you can use the "Content Hash" feature, available in the Java SDK as FileMetadata.contentHash, to verify if you've successfully downloaded the full and correct file contents.

View solution in original post

7 Replies 7
Highlighted

Re: is there a way we can resume downloads from where it left ?

Explorer | Level 4

like the file is not fully downloaded. The output stream is interrupted in the middle and the whole image data is not written into the file because of the interruption. Is there a way that we can keep track of the files that were not fully downloaded and retry them again?

Highlighted

Re: is there a way we can resume downloads from where it left ?

Dropboxer
Dropboxer

For cleaning up after failed operations, if an API call fails when you're using the Java SDK, it should raise an exception you can catch so you can perform whatever cleanup you need, such as deleting local files. 

For restarting downloads, you can actually use DbxDownloadStyleBuilder.range to restart a download at whatever point in the file you need. There's an example of using that in test test code here.

Highlighted

Re: is there a way we can resume downloads from where it left ?

Explorer | Level 4

Partially downloaded filePartially downloaded file

when I say partially downloaded. I mean like the one in the above picture .when I stop the program abruptly this happens because the output stream is interrupted before the file is fully written on disk.  Can you suggest anything to handle this case?

Highlighted

Re: is there a way we can resume downloads from where it left ?

Dropboxer
Dropboxer

Yes, it looks like in that case you've only written a portion of the file, so you could check how much of the file you did write, and then use DbxDownloadStyleBuilder.range to download just the rest of the file.

Also, if it's helpful, you can use the "Content Hash" feature, available in the Java SDK as FileMetadata.contentHash, to verify if you've successfully downloaded the full and correct file contents.

View solution in original post

Highlighted

Re: is there a way we can resume downloads from where it left ?

Explorer | Level 4

Thank you, Greg !! 

Highlighted

Re: is there a way we can resume downloads from where it left ?

Super Collaborator | Level 20

Hi @Greg K.,

I would ask you, why the range you mention isn't documented in HTTP documentation: https://www.dropbox.com/developers/documentation/http/documentation#files-download ? Could this lack of completeness be corrected?

ADD: For upload also.

Highlighted

Re: is there a way we can resume downloads from where it left ?

Dropboxer
Dropboxer

@Здравко The Dropbox API actually supports range requests for all content-download style endpoints in general, so it's mentioned in the "Content-download endpoints" documentation. That could definitely be expanded on though, so I'll ask the team to improve that. Thanks!

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

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?