Storage
"firebase/storage"
"firebase-admin/storage"
Google Cloud Storage
Firebase Storage is a wrapper around Google Cloud Storage, which is a cloud storage service similar to Amazon S3.
It is an object storage service because it stores objects in a bucket.
A firebase project is given a default bucket.
objects in a bucket
we use the term object instead of file to emphasize some differences:
- objects are immutable. We may not edit an object. We must create a new, distinct object. This is different from files that are writable and may change over time. We can technically have a similar outcome by creating a new object and storing it with the same name. In that case, we may describe it as a new generation.
- objects live in a single, flat container, whereas files usually live in a vertical hierarchy of directories. The flat layout allows to split up objects on different machines, which makes it easier for provider to accommodate large storage needs.
- the flat container is called a bucket. Within a bucket, we may emulate a hierarchy by adding subpaths to file names such as public/ in
public/abc.png
default's bucket's identifier and URI.
The bucket's name or identifier is a domain that uses the project's name, such as projectname.firebasestorage.app. It is unique because the project's name itself is (globally) unique.
projectname.firebasestorage.app
imagetales.firebasestorage.app
projectname.appspot.com # old domain name
the extended name or identifier is a fully-fledged URI, and uses the gs:// prefix.
gs://imagetales.firebasestorage.app
the domain name and the URI do not have a matching HTTP endpoint. If we attempt to visit them, it errors. Instead, they serve as an identifier.
specify a bucket
The client SDK picks the default bucket by default.
If we are to use a distinct bucket, we must provide its URI.
const storage = getStorage(app, bucketURI)
const storage = getStorage(app, "gs://...")
bucket information
gcloud storage buckets describe gs://imagetales.firebasestorage.app