pub struct LocalFs { /* private fields */ }Expand description
本地文件系统存储后端
支持按相对路径读写/删除文件,自动创建目录,自动推算 MIME 类型。
Implementations§
Source§impl LocalFs
impl LocalFs
Sourcepub async fn write(
&self,
relative_path: &str,
data: &[u8],
) -> StoreResult<FileMeta>
pub async fn write( &self, relative_path: &str, data: &[u8], ) -> StoreResult<FileMeta>
写入文件(relative_path 保留原始名称,UUID 作为 file_id)
Sourcepub async fn write_with_name(
&self,
original_name: &str,
data: &[u8],
) -> StoreResult<FileMeta>
pub async fn write_with_name( &self, original_name: &str, data: &[u8], ) -> StoreResult<FileMeta>
写入文件(自动按日期分目录:YYYY/MM/DD/uuid.ext)
比 write 更安全——上层无需关心路径命名。
Sourcepub async fn read(&self, relative_path: &str) -> StoreResult<Vec<u8>>
pub async fn read(&self, relative_path: &str) -> StoreResult<Vec<u8>>
读取文件全部内容
文件不存在返回 Err("文件不存在: ...")。
Sourcepub async fn delete(&self, relative_path: &str) -> StoreResult<()>
pub async fn delete(&self, relative_path: &str) -> StoreResult<()>
删除文件(不存在不报错)
Auto Trait Implementations§
impl Freeze for LocalFs
impl RefUnwindSafe for LocalFs
impl Send for LocalFs
impl Sync for LocalFs
impl Unpin for LocalFs
impl UnsafeUnpin for LocalFs
impl UnwindSafe for LocalFs
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