Pier Pier - 23 days ago 18x
Javascript Question

How to enable and use file versioning in Firebase Storage?

Firebase storage is based on Google Cloud Platform which allows versioning of files.

In the Firebase console there are no options regarding the GCP bucket, and when accessing the GCP console, there doesn't seem to be a way on enabling versioning in the bucket pertaining to the Firebase project.

Also, the Firebase SDK does not mention how to access previous versions of files even if versioning was enabled.

Is versioning possible with Firebase Storage?


Firebase Storage is built on GCS so many of the features of GCS can be accessed via Firebase Storage. Firebase Storage also shares a GCS bucket named <project-id>.appspot.com (or similar), that can be accessed via both the Firebase console and the Cloud console.

You can enable object versioning on your bucket by using the gsutil tool (probably the easiest way) like so:

gsutil versioning set on gs://<project-id>.appspot.com

That said, there's no way of using the Firebase Storage clients to retrieve anything other than the most recent version. This was intentional, since Firebase Storage provides a simpler, mobile focused subset of the GCS APIs, and we didn't have a super compelling use case for providing an intuitive object versioning story for mobile. Per user data backups (initiated by the user without dev intervention), and document diffs are the two I can think of, but if you've got another, we'd love to hear it :)

We anticipate that a majority of devs will turn this on in order to prevent deletions from being permanent (and indeed, we mention doing this in our delete docs), and will thus use tools like gsutil or their own custom backends to retrieve and restore the appropriate files.

EDIT 10/1: Since these use cases have become more common, we've updated our docs to include more things you can do with Google Cloud Platform in our GCP Integration guide.