Module storage

Module storage 

Source
Expand description

§Firebase Storage module.

This module ports core pieces of the Firebase Storage Web SDK to Rust so applications can discover buckets, navigate object paths, and perform common download, metadata, and upload operations in a synchronous, reqwest-powered environment.

It provides functionality to interact with Firebase Storage, including uploading and downloading files, managing metadata, and handling storage references.

It includes error handling, configuration options, and integration with Firebase apps.

§Features

  • Connect to Firebase Storage emulator
  • Get storage instance for a Firebase app
  • Register storage component
  • Manage storage references
  • Handle file uploads with progress tracking
  • List files and directories in storage
  • Manage object metadata
  • Comprehensive error handling

§References to the Firebase JS SDK - storage module

§Development status as of 14th October 2025

  • Core functionalities: Mostly implemented (see the module’s README for details)
  • Tests: 27 tests (passed)
  • Documentation: Lacking documentation on most functions
  • Examples: None provided

DISCLAIMER: This is not an official Firebase product, nor it is guaranteed that it has no bugs or that it will work as intended.

§Example

use firebase_rs_sdk::app::*;
use firebase_rs_sdk::storage::*;

fn main() {
    let options = FirebaseOptions {
        storage_bucket: Some("BUCKET_NAME".into()),
        ..Default::default()
    };

    let app = initialize_app(options, Some(FirebaseAppSettings::default()))
        .expect("failed to initialize app");

    let storage = get_storage_for_app(Some(app), None)
        .expect("storage component not available");

    let photos = storage
        .root_reference()
        .expect("missing default bucket")
        .child("photos");

    // Upload a photo; small payloads are sent via multipart upload while larger blobs use the resumable API.
    let image_bytes = vec![/* PNG bytes */];
    let mut upload_metadata = UploadMetadata::new().with_content_type("image/png");
    upload_metadata.insert_custom_metadata("uploaded-by", "quickstart");

    let metadata = photos
        .child("welcome.png")
        .upload_bytes(image_bytes, Some(upload_metadata))
        .expect("upload failed");
    println!("Uploaded {} to bucket {}", metadata.name.unwrap_or_default(), metadata.bucket.unwrap_or_default());

    // List the directory and stream the first few kilobytes of each item.
    let listing = photos.list_all().expect("failed to list objects");
    for object in listing.items {
        let url = object.get_download_url().expect("missing download URL");
        let bytes = object
            .get_bytes(Some(256 * 1024))
            .expect("download limited to 256 KiB");
        println!("{} -> {} bytes", url, bytes.len());
    }
}

Modules§

api
error
reference
request
service

Structs§

BackoffConfig
Configuration for exponential backoff when issuing storage requests.
BackoffState
Tracks the evolving backoff state across attempts.
FirebaseStorageImpl
HttpClient
ListOptions
ListResult
Location
ObjectMetadata
RequestInfo
ResponsePayload
ResumableUploadStatus
SetMetadataRequest
StorageError
StorageReference
UploadProgress
Progress information emitted while uploading large blobs.
UploadTask
Stateful helper that mirrors the Firebase Web SDK’s resumable upload behaviour.

Enums§

RequestBody
RequestError
StorageErrorCode
UploadTaskState
Represents the execution state of an UploadTask.

Constants§

DEFAULT_HOST
DEFAULT_MAX_OPERATION_RETRY_TIME_MS
DEFAULT_MAX_UPLOAD_RETRY_TIME_MS
DEFAULT_PROTOCOL
RESUMABLE_UPLOAD_CHUNK_SIZE
STORAGE_TYPE

Functions§

build_list_options
child
connect_storage_emulator
continue_resumable_upload_request
create_resumable_upload_request
delete_object_request
delete_storage_instance
download_bytes_request
download_url_request
get_metadata_request
get_resumable_upload_status_request
get_storage_for_app
is_retry_status_code
is_url
last_component
list_request
multipart_upload_request
parent
parse_list_result
register_storage_component
storage_ref_from_reference
storage_ref_from_storage
update_metadata_request

Type Aliases§

ResponseHandler
SettableMetadata
StorageResult
UploadMetadata