问题
I am currently using the Dropbox API to get details about files. So I need show the user the file version number. However, the rev
item will return a file version which is like "35c1f029684fe". This is not consistent with the Dropbox UI which shows Version 1 or Version 0. How can I get this version number?
回答1:
Having browsed through their file/folder metadata, I don't see any field that gives the number you want. Instead, you can use the revisions API.
https://api.dropbox.com/1/revisions/<root>/<path>
This returns something like:
[
{
"is_deleted": true,
"revision": 4,
"rev": "40000000d",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 20 Jul 2011 22:41:09 +0000",
"path": "/hi2",
"is_dir": false,
"icon": "page_white",
"root": "app_folder",
"mime_type": "application/octet-stream",
"size": "0 bytes"
},
{
"revision": 1,
"rev": "10000000d",
"thumb_exists": false,
"bytes": 3,
"modified": "Wed, 20 Jul 2011 22:40:43 +0000",
"path": "/hi2",
"is_dir": false,
"icon": "page_white",
"root": "app_folder",
"mime_type": "application/octet-stream",
"size": "3 bytes"
}
]
Note the revision numbers. There are a couple of caveats, though; some relevant snippets from the docs (emphasis mine):
Only revisions up to thirty days old are available (or more if the Dropbox user has Packrat). [...] rev_limit Default is 10. Max is 1,000. Up to this number of recent revisions will be returned.
It seems like the default parameters will return you the most recent revisions first. You can verify if this is the case; if so, it should meet your needs nicely.
来源:https://stackoverflow.com/questions/20601104/how-to-get-the-revision-of-an-item-with-dropbox-api