pub struct CopyFileBuilder<'a> { /* private fields */ }
Expand description
A builder to create a CopyFile request.
See https://www.backblaze.com/b2/docs/b2_copy_file.html for further information.
Implementations§
Source§impl<'a> CopyFileBuilder<'a>
impl<'a> CopyFileBuilder<'a>
Sourcepub fn source_file(self, file: &File) -> Self
pub fn source_file(self, file: &File) -> Self
Obtain the source file ID and encryption settings for the copy operation.
Sourcepub fn source_file_id(self, file: impl Into<String>) -> Self
pub fn source_file_id(self, file: impl Into<String>) -> Self
Set the source file ID of the file to copy.
Sourcepub fn destination_bucket_id(self, bucket: impl Into<String>) -> Self
pub fn destination_bucket_id(self, bucket: impl Into<String>) -> Self
Set the destination bucket for the new file.
If not provided, the same bucket ID as the source file is used.
Both buckets must belong to the same account.
Sourcepub fn destination_file_name(
self,
name: &'a str,
) -> Result<Self, FileNameValidationError>
pub fn destination_file_name( self, name: &'a str, ) -> Result<Self, FileNameValidationError>
Set the filename to use for the new file.
Sourcepub fn range(self, range: ByteRange) -> Self
pub fn range(self, range: ByteRange) -> Self
If provided, only copy the specified byte range of the source file.
Sourcepub fn metadata_directive(self, directive: MetadataDirective) -> Self
pub fn metadata_directive(self, directive: MetadataDirective) -> Self
Determine whether to copy the source metadata to the new file.
If MetadataDirective::Copy (the default), the source metadata will be copied to the new file.
If MetadataDirective::Replace, the new file’s metadata will be empty or determined by the information provided via content_type and file_info.
Sourcepub fn content_type(self, content_type: impl Into<String>) -> Self
pub fn content_type(self, content_type: impl Into<String>) -> Self
Set the content-type of the file.
The content-type can only be set if metadata_directive is MetadataDirective::Replace.
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.
The file information can only be set if metadata_directive is MetadataDirective::Replace.
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.
Sourcepub fn file_retention(self, retention: FileRetentionPolicy) -> Self
pub fn file_retention(self, retention: FileRetentionPolicy) -> Self
Set the file-retention settings for the new file.
Setting this requires Capability::WriteFileRetentions.
Sourcepub fn with_legal_hold(self) -> Self
pub fn with_legal_hold(self) -> Self
Enable legal hold status for the new file.
Sourcepub fn without_legal_hold(self) -> Self
pub fn without_legal_hold(self) -> Self
Do not enable legal hold status for the new file.
Sourcepub fn source_encryption_settings(self, settings: ServerSideEncryption) -> Self
pub fn source_encryption_settings(self, settings: ServerSideEncryption) -> Self
Specify the server-side encryption settings on the source file.
Calling source_file will set this from the file object.
Sourcepub fn destination_encryption_settings(
self,
settings: ServerSideEncryption,
) -> Self
pub fn destination_encryption_settings( self, settings: ServerSideEncryption, ) -> Self
Specify the server-side encryption settings for the destination file.
If not provided, the bucket’s default settings will be used.
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 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 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 build(self) -> Result<CopyFile<'a>, ValidationError>
pub fn build(self) -> Result<CopyFile<'a>, ValidationError>
Create a CopyFile object.
§Returns
Returns ValidationError::MissingData if the source file or destination filename are not set.
Returns ValidationError::Incompatible if the metadata_directive is MetadataDirective::Copy or was not provided AND content_type or file_info were set.