Struct qiniu_upload_token::UploadPolicyBuilder
source · [−]pub struct UploadPolicyBuilder { /* private fields */ }
Expand description
上传策略构建器
用于生成上传策略,一旦生成完毕,上传策略将无法被修改
Implementations
sourceimpl UploadPolicyBuilder
impl UploadPolicyBuilder
sourcepub fn new_policy_for_bucket(
bucket: impl Into<BucketName>,
upload_token_lifetime: Duration
) -> Self
pub fn new_policy_for_bucket(
bucket: impl Into<BucketName>,
upload_token_lifetime: Duration
) -> Self
为指定的存储空间生成的上传策略
允许用户上传文件到指定的存储空间,不限制上传客户端指定对象名称。
上传策略根据给出的客户端配置指定上传凭证有效期
sourcepub fn new_policy_for_object(
bucket: impl Into<BucketName>,
object: impl Into<ObjectName>,
upload_token_lifetime: Duration
) -> Self
pub fn new_policy_for_object(
bucket: impl Into<BucketName>,
object: impl Into<ObjectName>,
upload_token_lifetime: Duration
) -> Self
为指定的存储空间和对象名称生成的上传策略
允许用户以指定的对象名称上传文件到指定的存储空间。 上传客户端不能指定与上传策略冲突的对象名称。
上传策略根据给出的客户端配置指定上传凭证有效期
sourcepub fn new_policy_for_objects_with_prefix(
bucket: impl Into<BucketName>,
prefix: impl AsRef<str>,
upload_token_lifetime: Duration
) -> Self
pub fn new_policy_for_objects_with_prefix(
bucket: impl Into<BucketName>,
prefix: impl AsRef<str>,
upload_token_lifetime: Duration
) -> Self
为指定的存储空间和对象名称前缀生成的上传策略
允许用户以指定的对象名称前缀上传文件到指定的存储空间。 上传客户端指定包含该前缀的对象名称。
上传策略根据给出的客户端配置指定上传凭证有效期
sourcepub fn token_lifetime(&mut self, lifetime: Duration) -> &mut Self
pub fn token_lifetime(&mut self, lifetime: Duration) -> &mut Self
指定上传凭证有效期
sourcepub fn token_deadline(&mut self, deadline: SystemTime) -> &mut Self
pub fn token_deadline(&mut self, deadline: SystemTime) -> &mut Self
指定上传凭证过期时间
sourcepub fn insert_only(&mut self) -> &mut Self
pub fn insert_only(&mut self) -> &mut Self
仅允许创建新的对象,不允许覆盖和修改同名对象
sourcepub fn enable_mime_detection(&mut self) -> &mut Self
pub fn enable_mime_detection(&mut self) -> &mut Self
启用 MIME 类型自动检测
sourcepub fn disable_mime_detection(&mut self) -> &mut Self
pub fn disable_mime_detection(&mut self) -> &mut Self
禁用 MIME 类型自动检测
sourcepub fn return_url(&mut self, url: impl Into<String>) -> &mut Self
pub fn return_url(&mut self, url: impl Into<String>) -> &mut Self
Web 端文件上传成功后,浏览器执行 303 跳转的 URL
通常用于表单上传。
文件上传成功后会跳转到 <return_url>?upload_ret=<queryString>
,
<queryString>
包含 return_body()
内容。
如不设置 return_url
,则直接将 return_body()
的内容返回给客户端
sourcepub fn return_body(&mut self, body: impl Into<String>) -> &mut Self
pub fn return_body(&mut self, body: impl Into<String>) -> &mut Self
sourcepub fn callback<V: AsRef<[S]>, S: AsRef<str>>(
&mut self,
urls: V,
host: impl Into<String>,
body: impl Into<String>,
body_type: impl Into<String>
) -> &mut Self
pub fn callback<V: AsRef<[S]>, S: AsRef<str>>(
&mut self,
urls: V,
host: impl Into<String>,
body: impl Into<String>,
body_type: impl Into<String>
) -> &mut Self
sourcepub fn file_size_limitation(&mut self, size: impl RangeBounds<u64>) -> &mut Self
pub fn file_size_limitation(&mut self, size: impl RangeBounds<u64>) -> &mut Self
限定上传文件尺寸的范围
单位为字节
sourcepub fn mime_types<V: AsRef<[S]>, S: AsRef<str>>(
&mut self,
content_types: V
) -> &mut Self
pub fn mime_types<V: AsRef<[S]>, S: AsRef<str>>(
&mut self,
content_types: V
) -> &mut Self
限定用户上传的文件类型
指定本字段值,七牛服务器会侦测文件内容以判断 MIME 类型,再用判断值跟指定值进行匹配, 匹配成功则允许上传,匹配失败则返回 403 状态码
sourcepub fn object_lifetime(&mut self, lifetime: Duration) -> &mut Self
pub fn object_lifetime(&mut self, lifetime: Duration) -> &mut Self
对象生命周期
精确到天
sourcepub fn unset<Q>(&mut self, k: &Q) -> &mut Selfwhere
String: Borrow<Q>,
Q: ?Sized + Ord + Eq + Hash,
pub fn unset<Q>(&mut self, k: &Q) -> &mut Selfwhere
String: Borrow<Q>,
Q: ?Sized + Ord + Eq + Hash,
直接删除上传策略的键
sourcepub fn build(&self) -> UploadPolicy
pub fn build(&self) -> UploadPolicy
生成上传策略
sourcepub fn build_token(
&self,
credential: Credential,
opts: ToStringOptions
) -> StaticUploadTokenProvider
pub fn build_token(
&self,
credential: Credential,
opts: ToStringOptions
) -> StaticUploadTokenProvider
根据七牛认证信息直接生成上传凭证
Trait Implementations
sourceimpl Clone for UploadPolicyBuilder
impl Clone for UploadPolicyBuilder
sourcefn clone(&self) -> UploadPolicyBuilder
fn clone(&self) -> UploadPolicyBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for UploadPolicyBuilder
impl Debug for UploadPolicyBuilder
sourceimpl From<UploadPolicy> for UploadPolicyBuilder
impl From<UploadPolicy> for UploadPolicyBuilder
sourcefn from(policy: UploadPolicy) -> Self
fn from(policy: UploadPolicy) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for UploadPolicyBuilder
impl Send for UploadPolicyBuilder
impl Sync for UploadPolicyBuilder
impl Unpin for UploadPolicyBuilder
impl UnwindSafe for UploadPolicyBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
sourcefn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
Pipes by value. This is generally the method you want to use. Read more
sourcefn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows self
and passes that borrow into the pipe function. Read more
sourcefn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows self
and passes that borrow into the pipe function. Read more
sourcefn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.borrow()
into the pipe function. Read more
sourcefn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
sourcefn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.as_ref()
into the pipe function.
sourcefn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
sourceimpl<T> Tap for T
impl<T> Tap for T
sourcefn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Immutable access to the Borrow<B>
of a value. Read more
sourcefn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the BorrowMut<B>
of a value. Read more
sourcefn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Immutable access to the AsRef<R>
view of a value. Read more
sourcefn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Mutable access to the AsMut<R>
view of a value. Read more
sourcefn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the Deref::Target
of a value. Read more
sourcefn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the Deref::Target
of a value. Read more
sourcefn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls .tap()
only in debug builds, and is erased in release builds.
sourcefn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
sourcefn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
sourcefn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
sourcefn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
sourcefn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more