pub struct UploadFileBuilder<'a> { /* private fields */ }
Expand description
A builder to create an UploadFile request.
The file_name and sha1_checksum are required.
The combined length limit of content_disposition, content_language, expiration, cache_control, content_encoding, and custom headers is 7,000 bytes, unless self-managed encryption and/or file locks are enabled, in which case the limit is 2,048 bytes.
Implementations§
Source§impl<'a> UploadFileBuilder<'a>
impl<'a> UploadFileBuilder<'a>
Sourcepub fn file_name(
self,
name: impl AsRef<str>,
) -> Result<Self, FileNameValidationError>
pub fn file_name( self, name: impl AsRef<str>, ) -> Result<Self, FileNameValidationError>
The name of the file.
The provided name will be percent-encoded.
Sourcepub fn content_type(self, content_type: impl Into<Mime>) -> Self
pub fn content_type(self, content_type: impl Into<Mime>) -> Self
The MIME type of the file’s contents.
This will be returned in the Content-Type
header when downloading the
file.
If not specified, B2 will attempt to automatically set the content-type,
defaulting to application/octet-stream
if unable to determine its
type.
B2-recognized content-types can be viewed here
Sourcepub fn sha1_checksum(self, checksum: &'a str) -> Self
pub fn sha1_checksum(self, checksum: &'a str) -> Self
The SHA1 checksum of the file’s contents.
B2 will use this to verify the accuracy of the file upload, and it will
be returned in the header X-Bz-Content-Sha1
when downloading the file.
Sourcepub fn last_modified(self, time: DateTime<Utc>) -> Self
pub fn last_modified(self, time: DateTime<Utc>) -> Self
The time of the file’s last modification.
Sourcepub fn content_disposition(
self,
disposition: ContentDisposition,
) -> Result<Self, ValidationError>
pub fn content_disposition( self, disposition: ContentDisposition, ) -> Result<Self, ValidationError>
The value to use for the Content-Disposition
header when downloading
the file.
Note that the download request can override this value.
Sourcepub fn content_language(self, language: impl Into<String>) -> Self
pub fn content_language(self, language: impl Into<String>) -> Self
The value to use for the Content-Language
header when downloading the
file.
Note that the download request can override this value.
Sourcepub fn expiration(self, expiration: Expires) -> Self
pub fn expiration(self, expiration: Expires) -> Self
The value to use for the Expires
header when the file is downloaded.
Note that the download request can override this value.
Sourcepub fn cache_control(self, cache_control: CacheControl) -> Self
pub fn cache_control(self, cache_control: CacheControl) -> Self
The value to use for the Cache-Control
header when the file is
downloaded.
This would override the value set at the bucket level, and can be overriden by a download request.
Sourcepub fn content_encoding(self, encoding: ContentEncoding) -> Self
pub fn content_encoding(self, encoding: ContentEncoding) -> Self
The value to use for the Content-Encoding
header when the file is
downloaded.
Note that this can be overriden by a download request.
Sourcepub fn file_info(self, info: Value) -> Result<Self, ValidationError>
pub fn file_info(self, info: Value) -> Result<Self, ValidationError>
Set user-specified file metadata.
For the following headers, use their corresponding methods instead of setting the values here:
- X-Bz-Info-src_last_modified_millis: last_modified
- X-Bz-Info-large_file_sha1: sha1_checksum
- Content-Disposition: content_disposition
- Content-Language: content_language
- Expires: expiration
- Cache-Control: cache_control
- Content-Encoding: content_encoding
If any of the above are set here and via their methods, the value from the method will override the value specified here.
Any header names that do not begin with “X-Bz-Info-
” will have it
prepended to the supplied name.
Sourcepub fn with_legal_hold(self) -> Self
pub fn with_legal_hold(self) -> Self
Set a legal hold on the file.
Sourcepub fn without_legal_hold(self) -> Self
pub fn without_legal_hold(self) -> Self
Disable a legal hold on the file.
Sourcepub fn file_retention_mode(self, mode: FileRetentionMode) -> Self
pub fn file_retention_mode(self, mode: FileRetentionMode) -> Self
Set the file retention mode for the file.
The bucket must be File Lock-enabled and the Authorization must have Capability::WriteFileRetentions.
Sourcepub fn retain_until(self, time: DateTime<Utc>) -> Self
pub fn retain_until(self, time: DateTime<Utc>) -> Self
Set the expiration date and time of a file lock.
The bucket must be File Lock-enabled and the Authorization must have Capability::WriteFileRetentions.
Sourcepub fn encryption_settings(self, settings: ServerSideEncryption) -> Self
pub fn encryption_settings(self, settings: ServerSideEncryption) -> Self
Set the encryption settings to use for the file.
Sourcepub fn build(self) -> Result<UploadFile<'a>, ValidationError>
pub fn build(self) -> Result<UploadFile<'a>, ValidationError>
Build an UploadFile request.