storage folder size #5323
-
|
Hi there, Is there a way to find out a folder size from the storage API? bucket A -> FolderA (find out the total folder size) Do I need to list the entire bucket files and do a total sum? many thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Using list with the bucket and folder path is the easist way (IF the user has access to all the files you want to total) and then sum the loop. That is just like querying the storage object table on bucket and partial path, but you maintain compatibility if things change. There is really no structure called a folder, just path names in the object table. You could also write a function with sql to query the storage object table for the bucket and partial path and sum in sql. Then call it with an rpc call to return just the total. This is less work on client and would allow you to securely get a total of a "folder" even if the user does not have access to all the files. Of course then have to maintain if the storage object were to change much in the future. Edit: It is alot more complex but doable if you have "subfolders" and need their totals included. |
Beta Was this translation helpful? Give feedback.
Using list with the bucket and folder path is the easist way (IF the user has access to all the files you want to total) and then sum the loop. That is just like querying the storage object table on bucket and partial path, but you maintain compatibility if things change. There is really no structure called a folder, just path names in the object table.
You could also write a function with sql to query the storage object table for the bucket and partial path and sum in sql. Then call it with an rpc call to return just the total. This is less work on client and would allow you to securely get a total of a "folder" even if the user does not have access to all the files. Of course then have …