pub trait FileStorageSend:
Sync
+ 'static
+ Send {
// Required methods
fn store(
&self,
prefix: &str,
file: &UploadedFile,
) -> impl Future<Output = Result<StoredFile, Error>> + Send;
fn store_stream(
&self,
prefix: &str,
stream: &mut BufferedUpload,
) -> impl Future<Output = Result<StoredFile, Error>> + Send;
fn delete(
&self,
path: &str,
) -> impl Future<Output = Result<(), Error>> + Send;
fn exists(
&self,
path: &str,
) -> impl Future<Output = Result<bool, Error>> + Send;
}Expand description
Trait for persisting uploaded files to a storage backend.
Both in-memory (UploadedFile) and chunked (BufferedUpload) uploads
are supported. Implementors must be Sync + 'static so they can be
shared across async tasks behind an Arc<dyn FileStorageDyn>.
Use the storage() factory function to construct the
backend configured by UploadConfig, or instantiate
a concrete backend directly (e.g. LocalStorage).
Use FileStorageDyn (object-safe companion) for trait objects:
Arc<dyn FileStorageDyn>. Any type implementing FileStorage
automatically implements FileStorageDyn via a blanket impl.
Required Methods§
Sourcefn store(
&self,
prefix: &str,
file: &UploadedFile,
) -> impl Future<Output = Result<StoredFile, Error>> + Send
fn store( &self, prefix: &str, file: &UploadedFile, ) -> impl Future<Output = Result<StoredFile, Error>> + Send
Store a buffered in-memory file under prefix/.
A ULID-based unique filename is generated automatically. Returns the stored path and size on success.
Sourcefn store_stream(
&self,
prefix: &str,
stream: &mut BufferedUpload,
) -> impl Future<Output = Result<StoredFile, Error>> + Send
fn store_stream( &self, prefix: &str, stream: &mut BufferedUpload, ) -> impl Future<Output = Result<StoredFile, Error>> + Send
Store a chunked upload under prefix/.
Chunks are consumed from stream sequentially.
Returns the stored path and size on success.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.