Skip to main content

FileStorageDyn

Trait FileStorageDyn 

Source
pub trait FileStorageDyn:
    Send
    + Sync
    + 'static {
    // Required methods
    fn store<'a>(
        &'a self,
        prefix: &'a str,
        file: &'a UploadedFile,
    ) -> Pin<Box<dyn Future<Output = Result<StoredFile, Error>> + Send + 'a>>;
    fn store_stream<'a>(
        &'a self,
        prefix: &'a str,
        stream: &'a mut BufferedUpload,
    ) -> Pin<Box<dyn Future<Output = Result<StoredFile, Error>> + Send + 'a>>;
    fn delete<'a>(
        &'a self,
        path: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
    fn exists<'a>(
        &'a self,
        path: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>;
}
Expand description

Object-safe companion to FileStorage for use with Arc<dyn FileStorageDyn>.

This trait is automatically implemented for all types that implement FileStorage (or FileStorageSend).

Required Methods§

Source

fn store<'a>( &'a self, prefix: &'a str, file: &'a UploadedFile, ) -> Pin<Box<dyn Future<Output = Result<StoredFile, Error>> + Send + 'a>>

Store a buffered in-memory file under prefix/.

A ULID-based unique filename is generated automatically. Returns the stored path and size on success.

Source

fn store_stream<'a>( &'a self, prefix: &'a str, stream: &'a mut BufferedUpload, ) -> Pin<Box<dyn Future<Output = Result<StoredFile, Error>> + Send + 'a>>

Store a chunked upload under prefix/.

Chunks are consumed from stream sequentially. Returns the stored path and size on success.

Source

fn delete<'a>( &'a self, path: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>

Delete a file by its storage path (as returned by store).

Source

fn exists<'a>( &'a self, path: &'a str, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>

Return true if a file exists at the given storage path.

Implementors§