You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Lechucico's avatar
Lechucico
Helpful | Level 6
8 years ago

Metadata instanceof DeletedMetadata and FileMetadata

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.

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox 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's avatar
      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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,918 PostsLatest Activity: 2 days ago
334 Following

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!