pub struct UploadPolicyBuilder { /* private fields */ }
Expand description

上传策略构建器

用于生成上传策略,一旦生成完毕,上传策略将无法被修改

Implementations

为指定的存储空间生成的上传策略

允许用户上传文件到指定的存储空间,不限制上传客户端指定对象名称。

上传策略根据给出的客户端配置指定上传凭证有效期

为指定的存储空间和对象名称生成的上传策略

允许用户以指定的对象名称上传文件到指定的存储空间。 上传客户端不能指定与上传策略冲突的对象名称。

上传策略根据给出的客户端配置指定上传凭证有效期

为指定的存储空间和对象名称前缀生成的上传策略

允许用户以指定的对象名称前缀上传文件到指定的存储空间。 上传客户端指定包含该前缀的对象名称。

上传策略根据给出的客户端配置指定上传凭证有效期

指定上传凭证有效期

指定上传凭证过期时间

仅允许创建新的对象,不允许覆盖和修改同名对象

启用 MIME 类型自动检测

禁用 MIME 类型自动检测

设置文件类型

Web 端文件上传成功后,浏览器执行 303 跳转的 URL

通常用于表单上传。 文件上传成功后会跳转到 <return_url>?upload_ret=<queryString><queryString> 包含 return_body() 内容。 如不设置 return_url,则直接将 return_body() 的内容返回给客户端

上传成功后,自定义七牛云最终返回给上传端(在指定 return_url() 时是携带在跳转路径参数中)的数据

支持魔法变量自定义变量return_body 要求是合法的 JSON 文本。 例如 {"key": $(key), "hash": $(etag), "w": $(imageInfo.width), "h": $(imageInfo.height)}

上传成功后,七牛云向业务服务器发送 POST 请求的 URL 列表,Host,回调请求的内容以及其 Content-Type

七牛服务器会在上传成功后逐一回调 URL 直到有一个成功为止

如果给出的 host 为空字符串,则使用默认的 Host

body 参数必须不能为空,支持魔法变量自定义变量 body_type 参数表示 body 参数的 Content-Type,如果为空,则为默认的 application/x-www-form-urlencoded

自定义对象名称

支持魔法变量自定义变量forcefalse 时,save_as 字段仅当用户上传的时候没有主动指定对象名时起作用, forcetrue 时,将强制按 save_as 字段的内容命名

限定上传文件尺寸的范围

单位为字节

限定用户上传的文件类型

指定本字段值,七牛服务器会侦测文件内容以判断 MIME 类型,再用判断值跟指定值进行匹配, 匹配成功则允许上传,匹配失败则返回 403 状态码

对象生命周期

精确到天

直接设置上传策略的键值对

直接删除上传策略的键

生成上传策略

根据七牛认证信息直接生成上传凭证

重置上传策略构建器

重置构建器使得构建器可以被多次复用

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Should always be Self

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

The resulting type after obtaining ownership.

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

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

Attempts to convert self into T using TryInto<T>. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.