pub struct FileStorage { /* private fields */ }Expand description
File storage service for managing document uploads
Implementations§
Source§impl FileStorage
impl FileStorage
Sourcepub fn new(base_path: impl AsRef<Path>) -> Result<Self, String>
pub fn new(base_path: impl AsRef<Path>) -> Result<Self, String>
Create a new FileStorage with the given base path
Sourcepub async fn save_file(
&self,
building_id: Uuid,
filename: &str,
content: &[u8],
) -> Result<String, String>
pub async fn save_file( &self, building_id: Uuid, filename: &str, content: &[u8], ) -> Result<String, String>
Save a file to storage and return the relative file path Files are organized by building_id: /uploads/{building_id}/{filename}
Sourcepub async fn read_file(&self, relative_path: &str) -> Result<Vec<u8>, String>
pub async fn read_file(&self, relative_path: &str) -> Result<Vec<u8>, String>
Read a file from storage
Sourcepub async fn delete_file(&self, relative_path: &str) -> Result<(), String>
pub async fn delete_file(&self, relative_path: &str) -> Result<(), String>
Delete a file from storage
Sourcepub async fn file_exists(&self, relative_path: &str) -> bool
pub async fn file_exists(&self, relative_path: &str) -> bool
Check if a file exists
Trait Implementations§
Source§impl Clone for FileStorage
impl Clone for FileStorage
Source§fn clone(&self) -> FileStorage
fn clone(&self) -> FileStorage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl StorageProvider for FileStorage
impl StorageProvider for FileStorage
Source§fn save_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
building_id: Uuid,
filename: &'life1 str,
content: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn save_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
building_id: Uuid,
filename: &'life1 str,
content: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Persist a file and return the relative path that can later be used to read/delete it.
Source§fn read_file<'life0, 'life1, 'async_trait>(
&'life0 self,
relative_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_file<'life0, 'life1, 'async_trait>(
&'life0 self,
relative_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve the raw bytes and return them as a vector.
Auto Trait Implementations§
impl Freeze for FileStorage
impl RefUnwindSafe for FileStorage
impl Send for FileStorage
impl Sync for FileStorage
impl Unpin for FileStorage
impl UnwindSafe for FileStorage
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.