Skip to content
This repository has been archived by the owner on Apr 18, 2019. It is now read-only.

How can I get the size of a folder #61

Closed
vanderwijk opened this issue Dec 23, 2012 · 3 comments
Closed

How can I get the size of a folder #61

vanderwijk opened this issue Dec 23, 2012 · 3 comments

Comments

@vanderwijk
Copy link

I am trying to find out how to display the total size of a specific folder. When I do $dropbox->metaData('Folder Name') the result always shows [bytes] => 0 and [size] => 0 bytes even when there are files inside the folder.

Is there a way to get the folder size or is this a bug with Dropbox?

@vanderwijk
Copy link
Author

For future reference; I Came up with this code which adds up the sizes of all the files inside a folder to find out the size of the folder:

function mx_check_dropbox_size( $folder ) { global $dropbox; $foldersize = 0; $foldercontents = $dropbox -> metaData( $folder ); foreach( $foldercontents["body"] -> contents as $file ) { $foldersize += $file -> size; } if ( $foldersize == 0 ) echo '✘'; if ( $foldersize >= 20 ) echo '✔'; };

mx_check_dropbox_size( "Test/Folder" );

(The check for the foldersize and echo of the checkmark or cross is something I need for my app so you can ignore that)

The page that needs this code is going to call the mx_check_dropbox_size function about a hundred times, so I might run into some performance issues. This is why I would much rather get the folder size from the array that Dropbox is sending.

@BenExile
Copy link
Owner

Dropbox will always return 0 bytes for a directory as described here. It's a shame because to get the size of a folder, including files and folders within, you have to make several API calls. You could contact Dropbox regarding this issue but it is not something I can address, unfortunately.

@vanderwijk
Copy link
Author

Hi Ben, thanks for your reply. I have contacted Dropbox about this and their response was that my feedback would be passed on. Not sure if this means that they will actually do something about it :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants