We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

dega's avatar
dega
Explorer | Level 4
8 years ago
Solved

API V2 Modified date for specific revision of a file in Python

Hi,

I am trying to get the metadata for a specific revision of a file, 

with V1 I used to do:

 

metadata = client.metadata(FileName, list=False, file_limit=1, hash=None, rev=revN, include_deleted=False)
 

 then I had it in "metadata['modified']".

 

 

Now I can only see how to download a particular revision or get the metadata for the last N (up to 100) revisions of a file. What if I have more than 100 versions?

 

P.S.

How I can specify the revision in the path, as the SDK states for "file_download"?

 

files_download(path, rev=None)

Download a file from a user’s Dropbox.

Parameters    • path (str) – The path of the file to download.

                        • rev (Nullable) – Deprecated. Please specify revision in path instead. 

  • In this example, you would call like this:

     

    dbx.files_download('rev:2bc3d561afc23')

    You don't need to specify the file path itself. You just need the "rev:abc123" format. The rev string actually identifies the file without the use of the path.

5 Replies

  • iNeil's avatar
    iNeil
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 months ago

    Hello dega​,

    There has been a recent enhancement to the Dropbox API’s /2/files/list_revisions endpoint that may be helpful for your implementation. The endpoint now supports two new capabilities:

    • before_rev (optional request parameter): This allows you to request revisions that occurred before a specific revision ID. It can be set using the rev of the last entry from a previous response. Currently it is only supported when using path mode in your request.
    • has_more (response field): This boolean indicates whether additional revisions are available. If true, you can continue retrieving older revisions by making another call with the before_rev request parameter. If false, it means all available revisions have been returned, and there are no more entries to fetch.

    These updates have improved the pagination functionality for file revision history. However, this functionality is not yet available in the Dropbox SDKs. To use the new capabilities, you’ll need to make direct HTTP requests to the /2/files/list_revisions endpoint

    If you have any questions, please don’t hesitate to reach out to us.

    Best regards,
    API Support Team

  • dega's avatar
    dega
    Explorer | Level 4
    8 years ago
    aaaah! this was not so easy to understand from the guide (at least for me).
    Thanks!!!
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    In this example, you would call like this:

     

    dbx.files_download('rev:2bc3d561afc23')

    You don't need to specify the file path itself. You just need the "rev:abc123" format. The rev string actually identifies the file without the use of the path.

  • dega's avatar
    dega
    Explorer | Level 4
    8 years ago

    Hi Greg, yes being able to go back more than 100 revision I believe will be something very nice to have.

     

    Regarding the files_download, passing the revision inside the path, I tried this (and lots of different combinations):

    dbx.files_download(FileName + "?rev:u'2bc3d561afc23'")

    but it gives me an error, however 

    dbx.files_download(FileName)

    retrieves the latest file (as expected).

    Moreover

     dbx.files_download(FileName,u'2bc3d561afc23')

    retrieves the version I was looking for, so the revision string is correct.

     

    Am I missing something?

    I am tring to follow the guide not to implement something that will soon be deprecated.

     

    Thanks,
    Marco

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    API v2 only supports listing up to 100 revisions, but I'll pass this along as a feature request for more.

    To specify a particular revision in the `path` parameter, you should use a string like "rev:abc123" where abc123 is the rev string for the revision you want.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,035 PostsLatest Activity: 5 years ago
410 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!