pub struct AppStorage {
pub inner: Arc<dyn BlobStore>,
/* private fields */
}Expand description
App-state handle: backend + optional public URL prefix.
Fields§
§inner: Arc<dyn BlobStore>Implementations§
Source§impl AppStorage
impl AppStorage
pub fn new(store: Arc<dyn BlobStore>) -> Self
pub fn with_public_url(self, base: impl Into<String>) -> Self
Sourcepub fn url(&self, key: &str) -> Option<String>
pub fn url(&self, key: &str) -> Option<String>
Public URL for key when public_url was set (e.g. /assets/uploads/avatars/u1.png).
pub async fn put( &self, key: &str, data: Bytes, opts: PutOpts, ) -> Result<(), StorageError>
pub async fn get(&self, key: &str) -> Result<Option<Bytes>, StorageError>
pub async fn delete(&self, key: &str) -> Result<(), StorageError>
pub async fn exists(&self, key: &str) -> Result<bool, StorageError>
pub async fn list(&self, prefix: &str) -> Result<Vec<String>, StorageError>
Sourcepub async fn temporary_url(
&self,
key: &str,
expires: Duration,
) -> Result<String, StorageError>
pub async fn temporary_url( &self, key: &str, expires: Duration, ) -> Result<String, StorageError>
Presigned download URL (S3/GCS/Azure). Err on local/memory.
Sourcepub async fn temporary_upload_url(
&self,
key: &str,
expires: Duration,
) -> Result<String, StorageError>
pub async fn temporary_upload_url( &self, key: &str, expires: Duration, ) -> Result<String, StorageError>
Presigned upload URL (S3/GCS/Azure). Err on local/memory.
Sourcepub async fn put_upload(
&self,
key: &str,
upload: &Upload,
) -> Result<(), StorageError>
pub async fn put_upload( &self, key: &str, upload: &Upload, ) -> Result<(), StorageError>
Store an upload’s bytes under key (uses upload content-type when present).
Sourcepub async fn store(
&self,
upload: &Upload,
dir: &str,
) -> Result<StoredFile, StorageError>
pub async fn store( &self, upload: &Upload, dir: &str, ) -> Result<StoredFile, StorageError>
Store under dir + random name (extension from upload, fallback bin).
Validate with sova_core::UploadRules before calling.
Sourcepub async fn store_as(
&self,
upload: &Upload,
key: &str,
) -> Result<StoredFile, StorageError>
pub async fn store_as( &self, upload: &Upload, key: &str, ) -> Result<StoredFile, StorageError>
Store under an exact key; returns key + optional public URL.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AppStorage
impl !UnwindSafe for AppStorage
impl Freeze for AppStorage
impl Send for AppStorage
impl Sync for AppStorage
impl Unpin for AppStorage
impl UnsafeUnpin for AppStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more