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

上传策略

可以阅读 https://developer.qiniu.com/kodo/manual/1206/put-policy 了解七牛安全机制。

根据指定的存储空间和对象名称,生成可以用来上传低频存储类型文件的上传策略

use qiniu_upload_token::{FileType, UploadPolicy};
use std::time::Duration;

let upload_policy = UploadPolicy::new_for_object("your-bucket", "your-key", Duration::from_secs(3600))
    .file_type(FileType::InfrequentAccess)
    .build();

Implementations

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

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

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

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

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

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

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

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

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

存储空间约束

对象名称约束或对象名称前缀约束

是否是对象名称前缀约束

是否仅允许新增对象,不允许覆盖对象

是否启用 MIME 类型自动检测

上传凭证过期时间

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

上传成功后,自定义七牛云最终返回给上传端的数据

上传成功后,七牛云向业务服务器发送 POST 请求的 URL 列表

上传成功后,七牛云向业务服务器发送回调请求时的 Host

上传成功后,七牛云向业务服务器发送回调请求时的内容

支持魔法变量自定义变量

上传成功后,七牛云向业务服务器发送回调请求时的 Content-Type

默认为 application/x-www-form-urlencoded,也可设置为 application/json

自定义对象名称

支持魔法变量自定义变量

是否忽略客户端指定的对象名称,强制使用自定义对象名称进行文件命名

限定上传文件尺寸的范围

返回的第一个元素为最小尺寸,第二个元素为最大尺寸,如果为 None 表示不限制,单位为字节

限定用户上传的文件类型

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

文件类型

对象生命周期

精确到天

获取 JSON 格式的上传凭证

解析 JSON 格式的上传凭证

根据指定的上传策略字段获取相应的值

获取上传策略的字段迭代器

获取上传策略的字段值的迭代器

将上传策略转换为动态上传凭证提供者的实例

该方法与 UploadPolicy::into_static_upload_token_provider 的区别在于该方法接受 CredentialProvider 实例

将上传策略转换为静态上传凭证提供者的实例

该方法与 UploadPolicy::into_dynamic_upload_token_provider 的区别在于该方法只能接受 Credential 实例

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.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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.