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 moreAuto 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
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 more