最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to enable and use file versioning in Firebase Storage? - Stack Overflow

programmeradmin0浏览0评论

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 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?

Share asked Jun 6, 2016 at 18:54 PierPier 10.8k17 gold badges72 silver badges118 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

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. (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.

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 pelling 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 bee more mon, we've updated our docs to include more things you can do with Google Cloud Platform in our GCP Integration guide.

After Object Versioning enabled its possible to listing noncurrent object versions.

Get previous object version:

Long previousGeneration = ...;
byte[] previousContent = bucket.getStorage().get(BlobId.of(bucket.getName(), objectName, previousGeneration)).getContent();
发布评论

评论列表(0)

  1. 暂无评论