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:Ā 

Re: Python API V2 Metadata of root folder

Python API V2 Metadata of root folder

fapb88ve
Explorer | Level 4
Go to solution

Hello,

 

I see here that the previous version of the API had a way to check for the metadata of the root folder, but it seems that for this version of the API it is not supported. Is there anyway in particular that I could access that in the root folder? Thank you.

2 Accepted Solutions

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Yes, you should use files_list_folder and files_list_folder_continue to list the contents of any folder, including root. The root path is identified by the empty string "".

View solution in original post

Greg-DB
Dropbox Staff
Go to solution

The ListFolderResult.entries array contains Metadata objects. These can represent files, folders, or deleted items.  The entry would be a FileMetadata, FolderMetadata, or DeletedMetadata, respectively. These are all subclasses of Metadata, but size is only available on FileMetadata.

 

So, you should do something like this:

 

for entry in client.files_list_folder("").entries:
    print(entry.name)
    if isinstance(entry, dropbox.files.FileMetadata):
        print(entry.size)

 

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution

Yes, you should use files_list_folder and files_list_folder_continue to list the contents of any folder, including root. The root path is identified by the empty string "".

fapb88ve
Explorer | Level 4
Go to solution

Thanks, Greg. That solved it. One last question: I'm using the funciton you mentioned as follows:

'client.files_list_folder('').entries' ; it yields a FileMetadata response with the files' properties. Having that said, I noticed in the tutorial that you could pull the name of each file, but I'm also interested in pulling the size as well. I'm trying the following:

 

 

for i in client.files_list_folder("").entries:
    print(i.size)

 

But it's not working out. To me it's weird because I'm able to pull out the name property much in the same way. I'm not sure what's exactly wrong.

 

Sorry if this is a basic question, I'm starting out with python and the Dropbox API.

 

Thank you,

 

 

Greg-DB
Dropbox Staff
Go to solution

The ListFolderResult.entries array contains Metadata objects. These can represent files, folders, or deleted items.  The entry would be a FileMetadata, FolderMetadata, or DeletedMetadata, respectively. These are all subclasses of Metadata, but size is only available on FileMetadata.

 

So, you should do something like this:

 

for entry in client.files_list_folder("").entries:
    print(entry.name)
    if isinstance(entry, dropbox.files.FileMetadata):
        print(entry.size)

 

Need more support?