Search code examples
firebasefirebase-storage

Counting the number of files stored in Firebase Storage will count as a Storage Operation?


I'm wondering if the following code snippet will count as a Firebase Storage operation which could affect the costs regarding the FireBase Pricing plan?

Future<void> countFiles() async {
// Create a reference
var storageReference = FirebaseStorage.instance.ref().child("<directory-name>");

// Count the amount of files
var fileList = await storageReference.listAll();
setState(() {
  _fileCount = fileList.items.length;
});

Solution

  • Yes, listing objects is a billable operation. You will want to consult the Google Cloud documentation for details that:

    When an operation applies to a bucket, such as listing the objects in a bucket, the default storage class set for that bucket determines the operation cost.