Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object Lifecycle Management Firebase Storage

How to setup object lifecycle management in a firebase storage bucket. For example if i want to delete the files after 30 days of upload. Cannot find any documentation for firebase, but i can find for Google Storage.

Can we setup Object Lifecycle Management in a firebase bucket or any alternatives if there is no official method to do so.

like image 696
Sukrit Kumar Avatar asked Nov 30 '25 03:11

Sukrit Kumar


1 Answers

Firebase Storage Product Manager here:

Because Firebase Storage is backed by Google Cloud Storage, all the features of GCS, including Object Lifecycle Management, are available to Firebase Storage developers.

Object Lifecycle Management enables you to move data from one bucket type (such as Standard) to another (such as Durable Reduced Availability or Nearline), or delete an object after a certain amount of time.

Here's an example of how to delete objects after 30 days:

// 30DayTTL.json
{
    "rule":
    [
      {
        "action": {"type": "Delete"},
        "condition": {"age": 30}
      }
    ]
}

You can use that in the gsutil tool like this:

gsutil lifecycle set 30DayTTL.json gs://bucket.appspot.com

Note that this applies to all objects in a bucket, so if you want more granular Time to Live (TTL) functionality, you'll want to use multiple buckets or roll your own system as mentioned in the other answer.

like image 187
Mike McDonald Avatar answered Dec 01 '25 20:12

Mike McDonald