firebase.storage. Reference
Represents a reference to a Google Cloud Storage object. Developers can upload, download, and delete objects, as well as get/set object metadata.
Properties
bucket
string
The name of the bucket containing this reference's object.
fullPath
string
The full path of this object.
name
string
The short name of this object, which is the last component of the full path. For example, if fullPath is 'full/path/image.png', name is 'image.png'.
parent
nullable firebase.storage.Reference
A reference pointing to the parent location of this reference, or null if this reference is the root.
root
non-null firebase.storage.Reference
A reference to the root of this reference's bucket.
storage
non-null firebase.storage.Storage
The storage service associated with this reference.
Methods
child
child(path) returns firebase.storage.Reference
Returns a reference to a relative path from this reference.
Parameter |
|
|---|---|
|
path |
string The relative path from this reference. Leading, trailing, and consecutive slashes are removed. |
- Returns
-
non-null firebase.storage.ReferenceThe reference a the given path.
delete
delete() returns firebase.Promise containing void
Deletes the object at this reference's location.
- Returns
-
non-null firebase.Promise containing voidA Promise that resolves if the deletion succeeded and rejects if it failed, including if the object didn't exist.
getDownloadURL
getDownloadURL() returns firebase.Promise containing string
Fetches a long lived download URL for this object.
- Returns
-
non-null firebase.Promise containing stringA Promise that resolves with the download URL or rejects if the fetch failed, including if the object did not exist.
getMetadata
getMetadata() returns firebase.Promise containing firebase.storage.FullMetadata
Fetches metadata for the object at this location, if one exists.
- Returns
-
non-null firebase.Promise containing firebase.storage.FullMetadataA Promise that resolves with the metadata, or rejects if the fetch failed, including if the object did not exist.
put
put(data, metadata) returns firebase.storage.UploadTask
Uploads data to this reference's location.
Parameter |
|
|---|---|
|
data |
(non-null Blob, non-null Uint8Array, or non-null ArrayBuffer) The data to upload. |
|
metadata |
Optional firebase.storage.UploadMetadata Metadata for the newly uploaded object. Value must not be null. |
- Returns
-
non-null firebase.storage.UploadTaskAn object that can be used to monitor and manage the upload.
putString
putString(data, format, metadata) returns firebase.storage.UploadTask
Uploads string data to this reference's location.
Parameter |
|
|---|---|
|
data |
string The string to upload. |
|
format |
Optional The format of the string to upload. Value must not be null. |
|
metadata |
Optional firebase.storage.UploadMetadata Metadata for the newly uploaded object. Value must not be null. |
- Throws
-
If the format is not an allowed format, or if the given string doesn't conform to the specified format.
- Returns
-
non-null firebase.storage.UploadTask
toString
toString() returns string
Returns a gs:// URL for this object in the form
gs://<bucket>/<path>/<to>/<object>
- Returns
-
stringThe gs:// URL.
updateMetadata
updateMetadata(metadata) returns firebase.Promise containing firebase.storage.FullMetadata
Updates the metadata for the object at this location, if one exists.
Parameter |
|
|---|---|
|
metadata |
firebase.storage.SettableMetadata The new metadata. Setting a property to 'null' removes it on the server, while leaving a property as 'undefined' has no effect. Value must not be null. |
- Returns
-
non-null firebase.Promise containing firebase.storage.FullMetadataA Promise that resolves with the full updated metadata or rejects if the updated failed, including if the object did not exist.

