pub struct DirUploader { /* private fields */ }Expand description
Writes each upload into one directory as {uuid}-{basename} and stores its URL under
url_prefix; Panel::uploads_dir installs it and serves the
directory there.
Panel::new("admin")
.uploads(DirUploader::new("/uploads", "var/uploads"))
.serve_dir("/uploads/{*file}", "var/uploads");Implementations§
Source§impl DirUploader
impl DirUploader
Sourcepub fn new(
url_prefix: impl Into<String>,
dir: impl Into<PathBuf>,
) -> DirUploader
pub fn new( url_prefix: impl Into<String>, dir: impl Into<PathBuf>, ) -> DirUploader
Writes into dir, naming each file by a URL under url_prefix ("/uploads").
Sourcepub fn expire_pending(self, age: Duration) -> DirUploader
pub fn expire_pending(self, age: Duration) -> DirUploader
Marks each file it stores pending until the panel’s write that stores it commits, and
deletes a pending file once it is age old: the upload of a submission that never saved,
such as a refused form the user left. Panel::uploads_dir
sets 24 hours.
A store sweeps at most once an hour. Only the panel’s record forms keep what they store:
an app page that stores through this uploader and saves the path itself keeps it with
Uploader::keep, or uses an uploader without this setting.
Trait Implementations§
Source§impl Clone for DirUploader
impl Clone for DirUploader
Source§fn clone(&self) -> DirUploader
fn clone(&self) -> DirUploader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DirUploader
impl Debug for DirUploader
Source§impl Uploader for DirUploader
impl Uploader for DirUploader
Source§async fn holds(&self, _cx: &Cx, path: &str) -> bool
async fn holds(&self, _cx: &Cx, path: &str) -> bool
Whether the directory holds the file a URL store returned names. The name store writes
is the check, since the directory keeps no index of what it wrote: a file whose name it
would not write is not held.
Source§async fn keep(&self, _cx: &Cx, path: &str) -> Result<(), String>
async fn keep(&self, _cx: &Cx, path: &str) -> Result<(), String>
Drops the pending mark of the file a URL store returned names.