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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With