Skip to main content

FileStorage

Trait FileStorage 

Source
pub trait FileStorage: Send + Sync {
    // Required methods
    fn save<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        original_filename: &'life1 str,
        data: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<String, AdminError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdminError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn url(&self, path: &str) -> String;
}

Required Methods§

Source

fn save<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, original_filename: &'life1 str, data: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<String, AdminError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store data (raw bytes) and return the public URL/path to the stored file. original_filename is used only to preserve the file extension.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdminError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a stored file by its URL/path (as returned by save). Idempotent.

Source

fn url(&self, path: &str) -> String

Convert a stored path to a public URL. For LocalStorage this is a no-op (save already returns the URL). Custom backends may differ.

Implementors§