Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get storage space used in a folder in Firebase Storage

I'm creating a Firebase app that you can use to upload files. How can I get the amount of space used by a user in his folder (users/{userId}/{allPaths=**}) ?

like image 320
Zvi Karp Avatar asked Aug 04 '16 08:08

Zvi Karp


1 Answers

Great question. In short, there's no easy way to do this (even for us!) since this effectively requires that we recurse over an entire set of files and sum them all up. It's a pretty big mapreduce that isn't efficient to run every time a file is uploaded.

We do however, return the size of an individual file in the metadata.size property, so you can perform your own list call on a server (look at gcloud`) which will give you a list of files and "folders". Take the sizes of the files and add them up, then recurse and do the same for all subfolders. Sum them up, and write them something like the Firebase Realtime Database, where you can easily grab the folder sizes from clients.

like image 128
Mike McDonald Avatar answered Sep 21 '22 12:09

Mike McDonald