Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose way to keep track of a file's upload or download progress #37

Open
skela opened this issue Dec 16, 2015 · 12 comments
Open

Expose way to keep track of a file's upload or download progress #37

skela opened this issue Dec 16, 2015 · 12 comments

Comments

@skela
Copy link

skela commented Dec 16, 2015

Having an optional delegate method argument in the files_upload / files_download methods so that we can update progress UI and whatnot when uploading and downloading files would be really useful.

@cakoose
Copy link

cakoose commented Dec 16, 2015

This is possibly common enough to add special support. But for now, there are some workarounds.

files_download should be easy. It returns the file metadata object and the HTTP response object (from the Requests library). The file metadata object tells you how big the file is. The HTTP response object's raw field is a file-like object, so you can track progress as you repeatedly call read(4096).

files_upload is a little more work: take your original file-like data source, wrap it with your own object, and pass that to files_upload. When files_upload calls your wrapper's read(), you can assume all data read before that point has been uploaded (and perhaps call a delegate).

The assumption (that all the data read before the call to read() has been uploaded) isn't bulletproof, but it might be good enough. The upside is that these wrappers are general-purpose.

@mafrosis
Copy link

In the v1 API, the upload_chunk method returned an offset value - which is essentially the number of bytes uploaded. I use this for a progress bar in a CLI app at present. Does something of the sort exist in v2?

@skela
Copy link
Author

skela commented Dec 16, 2015

v2 has upload_session_start / upload_session_append / upload_session_finish, but its not exactly for this use-case I don't think. Besides there's still no progress update mechanism for download, so would certainly be useful to get that in there, shouldn't be hard at all.

@mafrosis
Copy link

👍 Yeah it should be straight forward enough. Awesome job on opening the client SDK on github - I have a fork of v1 with a single lonely patch which nowadays will be a pull request 😄

@skela
Copy link
Author

skela commented Dec 16, 2015

@cakoose thanks for the workaround, I'll take a look at doing that for now.

@skela
Copy link
Author

skela commented Dec 17, 2015

@cakoose your workaround is better than nothing, thanks!

@lakshmantgld
Copy link

@cakoose I am confused in using the return type of files_download_to_file. as per the documentation
dropbox sdk

The return types are metadata and request object. They are returned only after the file gets downloaded.
I don't know how to invoke the read(4096) in the returned request object.
Maybe I don't know how to use this.

Moreover in this case, tuple is returned. But when printing it, I find only the metadata.
screen shot 2015-12-23 at 3 29 51 pm
and the code for that piece is
screen shot 2015-12-23 at 3 31 07 pm

  • So, may be a small snippet on how to use read on the request object would be appreciated
  • In case of exceptions, like network time out, how to re-run it.( in simple a robust one)

Thanks in advance.

@cakoose
Copy link

cakoose commented Dec 23, 2015

Use files_download instead of files_download_to_file.

@aicpp
Copy link

aicpp commented May 20, 2016

@Lakshman-LD function files_download_to_file have mistake in their doc description.
really returns only FileMetadata.
line 259 at base.py:
return r[0]
There is need to fix documentation.

@garrett5688
Copy link

@aicpp thank you for pointing this out, was driving me crazy

@IanButterworth
Copy link

Has a way to track download progress with files_download_to_file been found/added?

@greg-db
Copy link
Contributor

greg-db commented Jan 4, 2019

@ianshmean No, unfortunately not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants