Returns a reference to a relative path from this reference.
const parent = firebase.storage().ref('invertase');
const ref = parent.child('logo.png');
The relative path from this reference. Leading, trailing, and consecutive slashes are removed.
Fetches metadata for the object at this location, if one exists.
const ref = firebase.storage().ref('invertase/logo.png');
const metadata = await ref.getMetadata();
console.log('Cache control: ', metadata.cacheControl);
List items (files) and prefixes (folders) under this storage reference.
List API is only available for Firebase Rules Version 2.
GCS is a key-blob store. Firebase Storage imposes the semantic of '/' delimited folder structure. Refer to GCS's List API if you want to learn more.
To adhere to Firebase Rules's Semantics, Firebase Storage does not support objects whose paths end with "/" or contain two consecutive "/"s. Firebase Storage List API will filter these unsupported objects. list() may fail if there are too many unsupported objects in the bucket.
const ref = firebase.storage().ref('/');
const results = await ref.list({
maxResults: 30,
});
Optionaloptions: FirebaseStorageTypes.ListOptionsAn optional ListOptions interface.
List all items (files) and prefixes (folders) under this storage reference.
This is a helper method for calling list() repeatedly until there are no more results. The default pagination size is 1000.
Note: The results may not be consistent if objects are changed while this operation is running.
Warning: listAll may potentially consume too many resources if there are too many results.
const ref = firebase.storage().ref('/');
const results = await ref.listAll();
Puts data onto the storage bucket.
const ref = firebase.storage().ref('invertase/new-logo.png');
const task = ref.put(BLOB, {
cacheControl: 'no-store', // disable caching
});
The data to upload to the storage bucket at the reference location.
Optionalmetadata: FirebaseStorageTypes.UploadMetadataPuts a file from local disk onto the storage bucket.
const ref = firebase.storage().ref('invertase/new-logo.png');
const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/new-logo.png`;
const task = ref.putFile(path, {
cacheControl: 'no-store', // disable caching
});
The local file path to upload to the bucket at the reference location.
Optionalmetadata: FirebaseStorageTypes.UploadMetadataAny additional UploadMetadata for this task.
Puts a string on the storage bucket. Depending on the string type, set a StringFormat type.
const ref = firebase.storage().ref('invertase/new-logo.png');
const task = ref.putString('PEZvbyBCYXI+', firebase.storage.StringFormat.BASE64, {
cacheControl: 'no-store', // disable caching
});
The string data, must match the format provided.
Optionalformat: "raw" | "base64" | "base64url" | "data_url"The format type of the string, e.g. a Base64 format string.
Optionalmetadata: FirebaseStorageTypes.UploadMetadataAny additional UploadMetadata for this task.
Updates the metadata for this reference object on the storage bucket.
const ref = firebase.storage().ref('invertase/nsfw-logo.png');
const updatedMetadata = await ref.updateMetadata({
customMetadata: {
'nsfw': 'true',
}
});
A SettableMetadata instance to update.
Downloads a file to the specified local file path on the device.
Get a Download Storage task to download a file:
const downloadTo = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/foobar.json`;
const task = firebase.storage().ref('/foo/bar.json').writeToFile(downloadTo);
The name of the bucket containing this reference's object.
The full path of this object.
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'.
A reference pointing to the parent location of this reference, or null if this reference is the root.
A reference to the root of this reference's bucket.
The storage service associated with this reference.
Represents a reference to a Google Cloud Storage object in React Native Firebase.
A reference can be used to upload and download storage objects, get/set storage object metadata, retrieve storage object download urls and delete storage objects.
Deprecated
Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
Example 1
Get a reference to a specific storage path.
Example 2
Get a reference to a specific storage path on another bucket in the same firebase project.