Crate firebase_storage

source ·
Expand description

Firebase Storage Rust SDK

The Firebase Storage Rust SDK provides a convenient way to interact with Firebase Storage in Rust applications. It utilizes the Firebase App SDK and API Request Utils crate to handle authentication and make API requests to Firebase Storage.

Usage

Here’s an example of how to use the Firebase Storage Rust SDK:

use firebase_app_sdk::App;
use firebase_storage_sdk::Storage;
use api_request_utils_rs::StatusCode;
#[tokio::main]
async fn main() -> std::result::Result<(), StatusCode> {
    // Initialize the Firebase app
    let app = App::initialize().await?;
 
    // Create a Firebase Storage instance
    let storage = Storage::new(&app);
 
    // Add a linked storage bucket to the Firebase project
    let bucket = storage.add_firebase().await?;
    println!("Bucket name: {}", bucket.name);
 
    // Remove the linked storage bucket from the Firebase project
    storage.remove_firebase().await?;
    println!("Bucket unlinked successfully.");
 
    // List the linked storage buckets for the Firebase project
    let result = storage.list("", 10).await?;
    println!("Buckets:");
    for bucket in result.buckets {
        println!("Bucket name: {}", bucket.name);
    }
    if let Some(next_page_token) = result.next_page_token {
        println!("Next page token: {}", next_page_token);
    }
 
    Ok(())
}

Structs

  • Represents a storage bucket in Firebase Storage.
  • Represents a collection of storage buckets with an optional next page token.
  • Represents the Firebase Storage service.