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 fn get_metadata(&self) -> StorageResult<ObjectMetadata>
pub 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 fn list(&self, options: Option<ListOptions>) -> StorageResult<ListResult>
pub fn list(&self, options: Option<ListOptions>) -> StorageResult<ListResult>
Lists objects and prefixes immediately under this reference.
Sourcepub fn list_all(&self) -> StorageResult<ListResult>
pub 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 fn update_metadata(
&self,
metadata: SettableMetadata,
) -> StorageResult<ObjectMetadata>
pub 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 fn get_bytes(
&self,
max_download_size_bytes: Option<u64>,
) -> StorageResult<Vec<u8>>
pub 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 fn get_download_url(&self) -> StorageResult<String>
pub fn get_download_url(&self) -> StorageResult<String>
Returns a signed download URL for the object.
Sourcepub fn delete_object(&self) -> StorageResult<()>
pub fn delete_object(&self) -> StorageResult<()>
Permanently deletes the object referenced by this path.
Sourcepub fn upload_bytes(
&self,
data: impl Into<Vec<u8>>,
metadata: Option<UploadMetadata>,
) -> StorageResult<ObjectMetadata>
pub 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())).unwrap();
let storage = get_storage_for_app(Some(app), None).unwrap();
let avatar = storage.root_reference().unwrap().child("avatars/user.png");
avatar.upload_bytes(vec![0_u8; 1024], None).unwrap();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.
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