Skip to main content

PutObjectOptions

Struct PutObjectOptions 

Source
pub struct PutObjectOptions {
Show 16 fields pub mime_type: Option<String>, pub cache_control: Option<String>, pub content_disposition: Option<String>, pub content_encoding: Option<ContentEncoding>, pub content_md5: Option<String>, pub expires: Option<String>, pub forbid_overwrite: Option<bool>, pub server_side_encryption: Option<ServerSideEncryptionAlgorithm>, pub server_side_data_encryption: Option<ServerSideEncryptionAlgorithm>, pub server_side_encryption_key_id: Option<String>, pub object_acl: Option<ObjectAcl>, pub storage_class: Option<StorageClass>, pub metadata: HashMap<String, String>, pub tags: HashMap<String, String>, pub callback: Option<Callback>, pub parameters: HashMap<String, String>,
}
Expand description

Options for putting object

Official document: https://help.aliyun.com/zh/oss/developer-reference/putobject

Fields§

§mime_type: Option<String>

文件的 mime_type。如果不指定,则从文件名猜测。如果猜测不到,则使用 application/octet-stream 如果是直接从字节数组创建 Object 的,则不会猜测这个值,建议显式指定

§cache_control: Option<String>

指定该 Object 被下载时网页的缓存行为。取值如下:

  • no-cache:不可直接使用缓存,而是先到服务端验证 Object 是否已更新。如果 Object 已更新,表明缓存已过期,需从服务端重新下载 Object;如果 Object 未更新,表明缓存未过期,此时将使用本地缓存。
  • no-store:所有内容都不会被缓存。
  • public:所有内容都将被缓存。
  • private:所有内容只在客户端缓存。
  • max-age=<seconds>:缓存内容的相对过期时间,单位为秒。此选项仅在 HTTP 1.1 中可用。示例:max-age=3600
§content_disposition: Option<String>

指定Object的展示形式。取值如下:

  • inline: 直接预览文件内容。
  • attachment: 以原文件名的形式下载到浏览器指定路径。
  • attachment; filename="yourFileName": 以自定义文件名的形式下载到浏览器指定路径。 yourFileName 用于自定义下载后的文件名称,例如 example.jpg

注意:

  • 如果 Object 名称包含星号(*)、正斜线(/)等特殊字符时,可能会出现特殊字符转义的情况。例如,下载 example*.jpg 到本地时,example*.jpg 可能会转义为example_.jpg
  • 如需确保下载名称中包含中文字符的 Object 到本地指定路径后,文件名称不出现乱码的现象,您需要将名称中包含的中文字符进行 URL 编码。例如,将测试.txt 从 OSS 下载到本地后,需要保留文件名为 测试.txt,需按照 "attachment;filename="+URLEncoder.encode("测试","UTF-8")+".txt;filename*=UTF-8''"+URLEncoder.encode("测试","UTF-8")+".txt" 的格式设置 Content-Disposition,即 attachment;filename=%E6%B5%8B%E8%AF%95.txt;filename*=UTF-8''%E6%B5%8B%E8%AF%95.txt
§content_encoding: Option<ContentEncoding>§content_md5: Option<String>

上传内容的 MD5 摘要算法结果的 base64 字符串。用于检查消息内容是否与发送时一致。Content-MD5 是由 MD5 算法生成的值。上传了 Content-MD5 请求头后,OSS 会计算消息体的 Content-MD5 并检查一致性。

§expires: Option<String>

过期时间。例如:Wed, 08 Jul 2015 16:57:01 GMT

§forbid_overwrite: Option<bool>

指定 PutObject 操作时是否覆盖同名 Object。

当目标 Bucket 处于已开启或已暂停的版本控制状态时, x-oss-forbid-overwrite 请求 Header 设置无效,即允许覆盖同名 Object。

  • 不指定 x-oss-forbid-overwrite 或者指定 x-oss-forbid-overwritefalse 时,表示允许覆盖同名 Object。
  • 指定 x-oss-forbid-overwritetrue 时,表示禁止覆盖同名 Object。

设置 x-oss-forbid-overwrite 请求 Header 导致 QPS 处理性能下降,如果您有大量的操作需要使用 x-oss-forbid-overwrite 请求 Header(QPS > 1000),请联系技术支持,避免影响您的业务。

§server_side_encryption: Option<ServerSideEncryptionAlgorithm>

创建 Object 时,指定服务器端加密方式。 指定此选项后,在响应头中会返回此选项,OSS 会对上传的 Object 进行加密编码存储。当下载该 Object 时,响应头中会包含 x-oss-server-side-encryption,且该值会被设置成此 Object 的加密算法。

§server_side_data_encryption: Option<ServerSideEncryptionAlgorithm>

指定Object的加密算法。如果未指定此选项,表明 Object 使用 AES256 加密算法。此选项仅当 x-oss-server-side-encryption 为 KMS 时有效。

§server_side_encryption_key_id: Option<String>

KMS托管的用户主密钥。此选项仅在 x-oss-server-side-encryption 为 KMS 时有效。

§object_acl: Option<ObjectAcl>

如果不指定,则默认采用 Bucket 的 ACL。

§storage_class: Option<StorageClass>

如果不指定,则默认采用 Bucket 的存储类型。

§metadata: HashMap<String, String>

使用 PutObject 接口时,如果配置以 x-oss-meta- 为前缀的参数,则该参数视为元数据,例如 x-oss-meta-location。 一个 Object 可以有多个类似的参数,但所有的元数据总大小不能超过 8 KB。 元数据支持短划线(-)、数字、英文字母(a~z)。英文字符的大写字母会被转成小写字母,不支持下划线(_)在内的其他字符。

注意:Key 必须是 x-oss-meta- 开头的

§tags: HashMap<String, String>

Object 标签

签合法字符集包括大小写字母、数字、空格和下列符号:+ - = . _ : /

§callback: Option<Callback>

For put_object only.

§parameters: HashMap<String, String>

额外的 URI 查询参数。

主要是初始化分片上传的时候,有一个额外参数 sequential, 但是这个参数在官方文档上都没有说明,所以就放到这里吧,有需要的话就使用

Trait Implementations§

Source§

impl Clone for PutObjectOptions

Source§

fn clone(&self) -> PutObjectOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PutObjectOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PutObjectOptions

Source§

fn default() -> PutObjectOptions

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PutObjectOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PutObjectOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,