Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

OGMC's avatar
OGMC
Helpful | Level 6
9 years ago
Solved

Python metadata help

In V1 as metadata was returned in a dictionary all i had to do was myMeta.get("name") to get the name of an item for examle.

 

Whats the best way to get direct info in V2

 

 

Do i have to regex the metadata object to get name or content hash or is there better way?        

 

 

  • I'm glad to hear you sorted this out already. Yes, you can directly access those fields like that, no regex necessary.

     

    For anyone else looking for this, here's that sample cleaned up:

     

    import dropbox
    
    dbx = dropbox.Dropbox("<ACCESS_TOKEN>")
    
    myDir = dbx.files_list_folder("")
    for item in myDir.entries:
        if isinstance(item, dropbox.files.FileMetadata):
            name = item.name
            fileID = item.id
            fileHash = item.content_hash
            print(name, fileID, fileHash)

2 Replies

Replies have been turned off for this discussion
  • OGMC's avatar
    OGMC
    Helpful | Level 6
    9 years ago

    ok i think i sussed this.

     

    so if i was was to do

     

     

    myDir = dbx.files_list_folder()
    for item in myDir:
        if isinstance(item, dropbox.filemetadata):
            name = item.name
            fileID = item.id
            fileHash = item.content_hash

     

    etc etc

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    I'm glad to hear you sorted this out already. Yes, you can directly access those fields like that, no regex necessary.

     

    For anyone else looking for this, here's that sample cleaned up:

     

    import dropbox
    
    dbx = dropbox.Dropbox("<ACCESS_TOKEN>")
    
    myDir = dbx.files_list_folder("")
    for item in myDir.entries:
        if isinstance(item, dropbox.files.FileMetadata):
            name = item.name
            fileID = item.id
            fileHash = item.content_hash
            print(name, fileID, fileHash)

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!