pub struct StorageReference { /* private fields */ }Implementations§
Source§impl StorageReference
impl StorageReference
pub fn storage(&self) -> FirebaseStorageImpl
pub fn location(&self) -> &Location
pub fn to_gs_url(&self) -> String
pub fn root(&self) -> StorageReference
pub fn bucket(&self) -> &str
pub fn full_path(&self) -> &str
pub fn name(&self) -> String
pub fn parent(&self) -> Option<StorageReference>
pub fn child(&self, segment: &str) -> StorageReference
Sourcepub async fn get_metadata(&self) -> StorageResult<ObjectMetadata>
pub async fn get_metadata(&self) -> StorageResult<ObjectMetadata>
Retrieves object metadata from Cloud Storage for this reference.
§Errors
Returns StorageError with code
storage/invalid-root-operation if the reference points to the bucket root.
Sourcepub async fn list(
&self,
options: Option<ListOptions>,
) -> StorageResult<ListResult>
pub async fn list( &self, options: Option<ListOptions>, ) -> StorageResult<ListResult>
Lists objects and prefixes immediately under this reference.
Sourcepub async fn list_all(&self) -> StorageResult<ListResult>
pub async fn list_all(&self) -> StorageResult<ListResult>
Recursively lists all objects beneath this reference.
This mirrors the Firebase Web SDK listAll helper and repeatedly calls list
until the backend stops returning a nextPageToken.
Sourcepub async fn update_metadata(
&self,
metadata: SettableMetadata,
) -> StorageResult<ObjectMetadata>
pub async fn update_metadata( &self, metadata: SettableMetadata, ) -> StorageResult<ObjectMetadata>
Updates mutable metadata fields for this object.
§Errors
Returns storage/invalid-root-operation
when invoked on the bucket root.
Sourcepub async fn get_bytes(
&self,
max_download_size_bytes: Option<u64>,
) -> StorageResult<Vec<u8>>
pub async fn get_bytes( &self, max_download_size_bytes: Option<u64>, ) -> StorageResult<Vec<u8>>
Downloads the referenced object into memory as a byte vector.
The optional max_download_size_bytes mirrors the Web SDK behaviour: when supplied the
backend is asked for at most that many bytes and the response is truncated if the server
ignores the range header.
Sourcepub async fn get_stream(
&self,
max_download_size_bytes: Option<u64>,
) -> StorageResult<StreamingResponse>
pub async fn get_stream( &self, max_download_size_bytes: Option<u64>, ) -> StorageResult<StreamingResponse>
Streams the referenced object as an async reader without buffering the entire payload.
Returns a StreamingResponse whose [StorageByteStream] can be consumed using the
standard tokio::io::AsyncRead interfaces.
§Examples
let response = reference.get_stream(None).await?;
let mut reader = response.reader;
let mut file = File::create("download.bin").await?;
copy(&mut reader, &mut file).await?;Sourcepub async fn get_download_url(&self) -> StorageResult<String>
pub async fn get_download_url(&self) -> StorageResult<String>
Returns a signed download URL for the object.
Sourcepub async fn delete_object(&self) -> StorageResult<()>
pub async fn delete_object(&self) -> StorageResult<()>
Permanently deletes the object referenced by this path.
Sourcepub async fn upload_bytes(
&self,
data: impl Into<Vec<u8>>,
metadata: Option<UploadMetadata>,
) -> StorageResult<ObjectMetadata>
pub async fn upload_bytes( &self, data: impl Into<Vec<u8>>, metadata: Option<UploadMetadata>, ) -> StorageResult<ObjectMetadata>
Uploads a small blob in a single multipart request.
§Examples
let options = FirebaseOptions {
storage_bucket: Some("my-bucket".into()),
..Default::default()
};
let app = initialize_app(options, Some(FirebaseAppSettings::default())).await?;
let storage = get_storage_for_app(Some(app), None).await?;
let avatar = storage.root_reference().unwrap().child("avatars/user.png");
avatar.upload_bytes(vec![0_u8; 1024], None).await?;Sourcepub fn upload_bytes_resumable(
&self,
data: Vec<u8>,
metadata: Option<UploadMetadata>,
) -> StorageResult<UploadTask>
pub fn upload_bytes_resumable( &self, data: Vec<u8>, metadata: Option<UploadMetadata>, ) -> StorageResult<UploadTask>
Creates a resumable upload task that can be advanced chunk by chunk or run to completion.
Resumable uploads stream data in 256 KiB chunks by default, doubling up to 32 MiB to match the
behaviour of the Firebase Web SDK. The returned crate::storage::upload::UploadTask
exposes helpers to poll chunk progress or upload the entire file with a single call.
Sourcepub async fn upload_string(
&self,
data: &str,
format: StringFormat,
metadata: Option<UploadMetadata>,
) -> StorageResult<ObjectMetadata>
pub async fn upload_string( &self, data: &str, format: StringFormat, metadata: Option<UploadMetadata>, ) -> StorageResult<ObjectMetadata>
Uploads a string using the specified StringFormat, mirroring the Web SDK’s uploadString helper.
Sourcepub async fn upload_reader_resumable<R>(
&self,
reader: R,
total_size: u64,
metadata: Option<UploadMetadata>,
) -> StorageResult<ObjectMetadata>where
R: UploadAsyncRead,
pub async fn upload_reader_resumable<R>(
&self,
reader: R,
total_size: u64,
metadata: Option<UploadMetadata>,
) -> StorageResult<ObjectMetadata>where
R: UploadAsyncRead,
Streams data from an AsyncRead source using the resumable upload API.
Sourcepub async fn upload_reader_resumable_with_progress<R, F>(
&self,
reader: R,
total_size: u64,
metadata: Option<UploadMetadata>,
progress: F,
) -> StorageResult<ObjectMetadata>
pub async fn upload_reader_resumable_with_progress<R, F>( &self, reader: R, total_size: u64, metadata: Option<UploadMetadata>, progress: F, ) -> StorageResult<ObjectMetadata>
Streams data from an AsyncRead source while reporting chunk progress.
Trait Implementations§
Source§impl Clone for StorageReference
impl Clone for StorageReference
Source§fn clone(&self) -> StorageReference
fn clone(&self) -> StorageReference
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more