Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Better late than never, I'm trying to migrate my Android app to API v2. Currently, when downloading a file from a user's linked Dropbox account, I first obtain the file revision...
@Override protected Boolean doInBackground(Void... params) { try { // Get Dropbox file revision Entry metadata = mDbxApi.metadata(mPath+mFilename, 5, null, true, null); String dbxFileRev = metadata.rev;
I'm struggling to workout how to do this in V2 because it seems I have to somehow use FileMetadata instead.
FileMetadata metadata = ?? mPath+mFilename ?? String dbxFileRev = metadata.getRev();
As you can guess, I'm a hobby developer and not a pro!
Many thanks,
M.
OK so I worked it out and it's really simple - you just cast to FileMetadata...
FileMetadata metadata = (FileMetadata) mDbxClient.files().getMetadata(mPath+mFilename); String dbxFileRev = metadata.getRev();
If the file is not found, it'll throw a 'FileNotFoundException'
OK so I worked it out and it's really simple - you just cast to FileMetadata...
FileMetadata metadata = (FileMetadata) mDbxClient.files().getMetadata(mPath+mFilename); String dbxFileRev = metadata.getRev();
If the file is not found, it'll throw a 'FileNotFoundException'
I'm glad to see you found this already. Yes, some properties are only available on FileMetadata, which is a subclass of Metadata, so you need to cast objects as necessary.
There's an example of how you can check for this here:
What is mPath??
Is it /App_folder_name/filename ??
@VarunRaj The getMetadata method takes the path to the file you're looking for as the "path" parameter. In the sample above, the value being passed in is "mPath+mFilename", which would mean that "mPath" is the path to the parent folder that contains the file with name "mFilename", if any.
Note that if you're using an app with the app folder permission, you should not explicitly pass in the app folder name. You just operate relative to the app folder, so for example, to reference a file "test.txt" direclty in the app folder, you would just pass in "/test.txt".
You can also get the path from the pathLower property on Metadata entries, e.g., as returned by listFolder.
Hi there!
If you need more help you can view your support options (expected response time for a 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!