获取Firebase Storage的文件夹中使用的存储空间 [英] Get storage space used in a folder in Firebase Storage

查看:169
本文介绍了获取Firebase Storage的文件夹中使用的存储空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Firebase应用程序,可用于上传文件.如何获得用户在其文件夹(users/{userId}/{allPaths=**})中使用的空间量?

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=**}) ?

推荐答案

好问题.简而言之,没有简单的方法可以做到这一点(即使对我们来说也是如此!),因为这实际上需要我们递归遍历整个文件集并将它们加总.这是一个很大的mapreduce,每次上传文件时运行效率都不高.

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.

但是,我们会在metadata.size属性中返回单个文件的大小,因此您可以在服务器上执行自己的list调用(请参见

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.

这篇关于获取Firebase Storage的文件夹中使用的存储空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆