cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Metadata instanceof DeletedMetadata and FileMetadata

Metadata instanceof DeletedMetadata and FileMetadata

Lechucico
Helpful | Level 6

Hello,

 

I would like to know if there's any way of check if the Metadata of a certain entry is of type DeletedMetadata and FileMetada but not FolderMetadata.

 

Like the following:

 

 

if (entry instanceof DeletedMetadata && entry instanceof FileMetadata) {
log.info("Deleted file: "+entry.getPathLower()); }

 

That's why I only store files on my application and I don't need to deal with the folders deleted.

 

3 Replies 3

Greg-DB
Dropbox Staff

Using instanceof is the right way to check the type of a Metadata object, as shown in this example.

 

Note that FileMetadata, DeletedMetadata, and FolderMetadata are mutually exclusive though. That is, any given Metadata object can only be one of those three subclasses, but not two of the three. For example, a DeletedMetadata only tells you that it represents a deleted item, and not whether it was a file or folder (or both) previously. That being the case, your "&&" here won't work, as nothing can be both FileMetadata and DeletedMetadata

 

It sounds like you want to know if a particular entry is for a deleted file. The API doesn't exactly support this, as a deleted entry could have been a file or folder or both in the past. That being the case, you can either keep track of what you last saw at that path, in order to check what it was previously, or call listRevisions to see what was previously there.

Lechucico
Helpful | Level 6

I've found a problem. By default, folders doesn't seem to have revision, since if I try to list revisions for a folder an exception raises.

 

But there's a problem:

 

When I receive a webhook with a DeleteMetadata I check the list revision of that path for see what was there before, and there's a problem:

 

  1. I create a file 'hello' without extension.
  2. I Remove it.
  3. I create a folder 'hello'
  4. Now if I remove the folder, the revisions of the old file appears.

When are removed the revisions?

 

I've cleaned the bin and revisions still appears from that file.

Greg-DB
Dropbox Staff
That's correct, folders are not considered to have revisions.

File revisions are stored for 30 days by default, or longer depending on the account type/features: https://www.dropbox.com/help/space/older-versions
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Lechucico Helpful | Level 6
What do Dropbox user levels mean?