Closed vanderwijk closed 11 years ago
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.
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.
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 :)
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?