pub struct FileInput { /* private fields */ }Expand description
A file to process: a local path, bytes in memory, an async reader, or a document that is already stored.
Anything path-like converts into a FileInput, so most calls take a plain string:
use wellfriend::FileInput;
wf.tools().compress_pdf("scan.pdf", None).await?; // a path
wf.tools().compress_pdf(FileInput::bytes(data, "scan.pdf"), None).await?; // bytes
wf.tools().compress_pdf(FileInput::document("doc_8kq2W1"), None).await?; // storedThe content type is taken from the file name’s extension.
Implementations§
Source§impl FileInput
impl FileInput
Sourcepub fn bytes(data: impl Into<Bytes>, filename: impl Into<String>) -> Self
pub fn bytes(data: impl Into<Bytes>, filename: impl Into<String>) -> Self
Bytes in memory, with the file name to store them under.
Sourcepub fn file(file: File, filename: impl Into<String>) -> Self
pub fn file(file: File, filename: impl Into<String>) -> Self
An open file, streamed from its current position to the end.
Sourcepub fn reader(
reader: impl AsyncRead + Send + Unpin + 'static,
size: u64,
filename: impl Into<String>,
) -> Self
pub fn reader( reader: impl AsyncRead + Send + Unpin + 'static, size: u64, filename: impl Into<String>, ) -> Self
Any async reader with its exact size in bytes. Files above the resumable-upload threshold
are sent in parts, holding one part (8 MiB) in memory at a time; above 50 MiB the API
needs the file’s SHA-256, so give it with FileInput::with_sha256 or pass a path.
Sourcepub fn document(document_id: impl Into<String>) -> Self
pub fn document(document_id: impl Into<String>) -> Self
A document already stored in the workspace (its current version). Nothing is uploaded.
Sourcepub fn version(
document_id: impl Into<String>,
version_id: impl Into<String>,
) -> Self
pub fn version( document_id: impl Into<String>, version_id: impl Into<String>, ) -> Self
One immutable version of a stored document. Nothing is uploaded.
Sourcepub fn with_filename(self, filename: impl Into<String>) -> Self
pub fn with_filename(self, filename: impl Into<String>) -> Self
Stores the upload under this file name instead of the path’s own name.
Sourcepub fn with_content_type(self, content_type: impl Into<String>) -> Self
pub fn with_content_type(self, content_type: impl Into<String>) -> Self
Sends this content type instead of the one detected from the file name.
Sourcepub fn with_sha256(self, sha256: impl Into<String>) -> Self
pub fn with_sha256(self, sha256: impl Into<String>) -> Self
The file’s SHA-256 in hex, when you already know it. Lets the API skip storing bytes it already has, and is required for reader inputs above 50 MiB.
Sourcepub fn is_document(&self) -> bool
pub fn is_document(&self) -> bool
True for an input that refers to a stored document.