Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Am trying to implement an API automation process to identify empty/0 bytes folders so I can delete them, similar to what was asked here.
I can't find 'size' attribute for folders in my requests response, my code is:-
import requests
import json
url = "https://api.dropboxapi.com/2/files/list_folder"
headers = {
"Authorization": "Bearer <access-token>",
"Content-Type": "application/json"
}
data = {
"path": "/Cat Watching Test",
"recursive": True
}
r = requests.post(url, headers=headers, data=json.dumps(data))
How do I calculate the size of folders from the API?
@_shintaku_ wrote:...
I can't find 'size' attribute for folders in my requests response, my code is:-
...
Hi @_shintaku_,
You can't find 'size' attribute cosa there is NOT such. Only files eventually residing in particular folder have such attribute on enumeration. To calculate total size, you need to enumerate entire folder content recursively and sum all files size (I'm still not certain that you need it actually).
You task can get up much easier if you check only for available entries in particular folder. If there are no any entries (files or folders) the folder is... empty. Isn't it much easier (no recursion, no calculations, etc)? On the post you provide link to, Greg posted some additional helpful tips, able to help automation for such a process (changes detection). Is something left no clear there?
Hope this helps.
Thanks.
Your suggestion on checking folder for entries was what I used.
Hi there!
If you need more help you can view your support options (expected response time for a 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!