pub struct FileService { /* private fields */ }Expand description
File-operations service: writes bytes to ObjectStorage and the
matching row to the stored_files table.
Implementations§
Source§impl FileService
impl FileService
pub fn new( storage: Arc<dyn ObjectStorage>, files: Arc<StoredFileRepository>, config: Arc<BucketConfig>, ) -> Self
Sourcepub async fn upload(
&self,
body: Bytes,
meta: FileMeta,
) -> BucketResult<StoredFile>
pub async fn upload( &self, body: Bytes, meta: FileMeta, ) -> BucketResult<StoredFile>
Upload with an auto-generated UUID storage key.
The produced key has shape {uuid}/{sanitized_name} — stable
across renames, avoids accidental collisions, but not human
readable. Use Self::upload_with_key when the URL matters.
Sourcepub async fn upload_with_key(
&self,
key: &str,
body: Bytes,
meta: FileMeta,
) -> BucketResult<StoredFile>
pub async fn upload_with_key( &self, key: &str, body: Bytes, meta: FileMeta, ) -> BucketResult<StoredFile>
Upload under an explicit key.
Keys beginning with public_prefix route to the public bucket
(handled inside the ObjectStorage impl). When the backend has
no public bucket configured, the key still writes to the private
bucket and a debug log event records the mismatch — dev
environments without a public bucket still work, but operators
can grep for the event before promoting a misconfiguration to
production.
Auto Trait Implementations§
impl !RefUnwindSafe for FileService
impl !UnwindSafe for FileService
impl Freeze for FileService
impl Send for FileService
impl Sync for FileService
impl Unpin for FileService
impl UnsafeUnpin for FileService
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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.