cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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: 

python SDK

python SDK

app5000
Explorer | Level 3

what is the difference between Dropbox.files_get_metadata and dropbox.files.FileMetadata? Which one should I use to get file server_Modified time?

1 Accepted Solution

Accepted Solutions

Re: python SDK

Greg-DB
Dropboxer

Dropbox.files_get_metadata is a method, which you can use to get metadata for a file or folder. dropbox.files.FileMetadata is the class used to represent metadata for a file.

 

For example, when you call Dropbox.files_get_metadata for a file, it will return an instance of dropbox.files.FileMetadata. You can the get the server modified time via dropbox.files.FileMetadata.server_modified, that is, the server_modified attribute of the FileMetadata instance.

 

For example, that would look like this:

metadata = dbx.files_get_metadata("/test.txt")
print("File: %s" % metadata.name)
print("Server modified time: %s" % metadata.server_modified)

 

 

View solution in original post

5 Replies 5

Re: python SDK

Greg-DB
Dropboxer

Dropbox.files_get_metadata is a method, which you can use to get metadata for a file or folder. dropbox.files.FileMetadata is the class used to represent metadata for a file.

 

For example, when you call Dropbox.files_get_metadata for a file, it will return an instance of dropbox.files.FileMetadata. You can the get the server modified time via dropbox.files.FileMetadata.server_modified, that is, the server_modified attribute of the FileMetadata instance.

 

For example, that would look like this:

metadata = dbx.files_get_metadata("/test.txt")
print("File: %s" % metadata.name)
print("Server modified time: %s" % metadata.server_modified)

 

 

View solution in original post

Re: python SDK

app5000
Explorer | Level 3

Thank you Greg for your quick reply.  The answer is very clear but dropbox documentation is hard to follow.  In it, the Return type is:
dropbox.files.Metadata NOT dropbox.files.FileMetadata for Dropbox.files_get_metadata method.  I checked on dropbox.files.Metadata and it does not include server_Modified attribute.  SO maybe your doc is not up to date?

Re: python SDK

Greg-DB
Dropboxer

The documentation is accurate. dropbox.files.FileMetadata is a subclass of dropbox.files.Metadata.

 

The files_get_metadata method will return an instance of dropbox.files.Metadata. That will be an instance of dropbox.files.FileMetadata for files, dropbox.files.FolderMetadata for folders, or dropbox.files.DeletedMetadata for a deleted item.

 

You can use isinstance to check if the instance is a file, etc., as shown here:

 

https://github.com/dropbox/dropbox-sdk-python/blob/350e6e23feb2b5fb302e808695c228d49648ffdd/example/...

Re: python SDK

app5000
Explorer | Level 3

Thank you.  This helps a lot.  Maybe your doc can have a page showing all the methods, then a page showing all the classes etc.  It is hard to follow when they are all mixed together.

Re: python SDK

Greg-DB
Dropboxer
Thanks for the feedback!
Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    app5000 Explorer | Level 3
What do Dropbox user levels mean?
Need more support?