React Native Firebase
    Preparing search index...

    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.

    Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.

    Get a reference to a specific storage path.

    const ref = firebase.storage().ref('invertase/logo.png');
    

    Get a reference to a specific storage path on another bucket in the same firebase project.

    const ref = firebase.storage().refFromURL('gs://other-bucket/invertase/logo.png');
    
    interface Reference {
        bucket: string;
        fullPath: string;
        name: string;
        parent: FirebaseStorageTypes.Reference | null;
        root: FirebaseStorageTypes.Reference;
        storage: FirebaseStorageTypes.Module;
        child(path: string): FirebaseStorageTypes.Reference;
        delete(): Promise<void>;
        getDownloadURL(): Promise<string>;
        getMetadata(): Promise<FirebaseStorageTypes.FullMetadata>;
        list(
            options?: FirebaseStorageTypes.ListOptions,
        ): Promise<FirebaseStorageTypes.ListResult>;
        listAll(): Promise<FirebaseStorageTypes.ListResult>;
        put(
            data: Blob | ArrayBuffer | Uint8Array<ArrayBufferLike>,
            metadata?: FirebaseStorageTypes.UploadMetadata,
        ): FirebaseStorageTypes.Task;
        putFile(
            localFilePath: string,
            metadata?: FirebaseStorageTypes.UploadMetadata,
        ): FirebaseStorageTypes.Task;
        putString(
            data: string,
            format?: "raw" | "base64" | "base64url" | "data_url",
            metadata?: FirebaseStorageTypes.UploadMetadata,
        ): FirebaseStorageTypes.Task;
        toString(): string;
        updateMetadata(
            metadata: FirebaseStorageTypes.SettableMetadata,
        ): Promise<FirebaseStorageTypes.FullMetadata>;
        writeToFile(localFilePath: string): FirebaseStorageTypes.Task;
    }
    Index

    Methods

    • Deletes the object at this reference's location.

      const ref = firebase.storage().ref('invertase/logo.png');
      await ref.delete();

      Returns Promise<void>

    • Fetches a long lived download URL for this object.

      const ref = firebase.storage().ref('invertase/logo.png');
      const url = await ref.getDownloadURL();

      Returns Promise<string>

    • 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,
      });

      Parameters

      Returns Promise<FirebaseStorageTypes.ListResult>

    • 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();

      Returns Promise<FirebaseStorageTypes.ListResult>

    • 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
      });

      Parameters

      • data: string

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

        Any additional UploadMetadata for this task.

      Returns FirebaseStorageTypes.Task

    • Returns a gs:// URL for this object in the form gs://<bucket>/<path>/<to>/<object>.

      const ref = firebase.storage().ref('invertase/logo.png');
      console.log('Full path: ', ref.toString()); // gs://invertase.io/invertase/logo.png

      Returns string

    • 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);

      Parameters

      • localFilePath: string

      Returns FirebaseStorageTypes.Task

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

    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.