Skip to content

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

Closed

Description

@skela

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.

Activity

  1. cakoose commented on Dec 16, 2015

    @cakoose

    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.

  2. mafrosis commented on Dec 16, 2015

    @mafrosis

    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?

  3. skela commented on Dec 16, 2015

    @skela
    Author

    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.

  4. mafrosis commented on Dec 16, 2015

    @mafrosis

    👍 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 😄

  5. skela commented on Dec 16, 2015

    @skela
    Author

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

  6. skela commented on Dec 17, 2015

    @skela
    Author

    @cakoose your workaround is better than nothing, thanks!

  7. lakshmantgld commented on Dec 23, 2015

    @lakshmantgld

    @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.

  8. cakoose commented on Dec 23, 2015

    @cakoose

    Use files_download instead of files_download_to_file.

  9. aicpp commented on May 20, 2016

    @aicpp

    @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.

  10. garrett5688 commented on May 26, 2016

    @garrett5688

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

  11. IanButterworth commented on Jan 4, 2019

    @IanButterworth

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

  12. greg-db commented on Jan 4, 2019

    @greg-db
    Contributor

    @ianshmean No, unfortunately not.

  13. AndreyVMarkelov commented on Aug 17, 2026

    @AndreyVMarkelov
    Contributor

    Closing as completed by #581.

    The new dropbox.file_transfer API supports progress callbacks for both uploads and downloads through UploadOptions.progress and DownloadOptions.progress.

    This is implemented in the new higher-level transfer helpers rather than directly on the generated files_upload / files_download methods.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions