Expand description

qiniu-upload-token

七牛 上传策略 / 上传凭证 库

负责配置七牛对象上传所需要的上传策略,并提供生成上传凭证的库函数,同时提供 UploadTokenProvider 方便扩展获取上传凭证的方式。 同时提供阻塞接口和异步接口(异步接口需要启用 async 功能)。 提供 UploadTokenProvider 的多个实现方式,例如:

代码示例

创建上传策略,并基于该策略创建凭证
use qiniu_upload_token::{FileType, UploadPolicy, credential::Credential, prelude::*};
use std::time::Duration;

let upload_policy = UploadPolicy::new_for_object("your-bucket", "your-key", Duration::from_secs(3600))
    .file_type(FileType::InfrequentAccess)
    .build();
let credential = Credential::new("your-access-key", "your-secret-key");
let upload_token = upload_policy.into_static_upload_token_provider(credential, Default::default());
println!("{}", upload_token);
从其他应用程序生成的上传凭证解析出上传策略
use qiniu_upload_token::{StaticUploadTokenProvider, prelude::*};

let upload_token: StaticUploadTokenProvider = "your-access-key:qRD-BSf_XGtovGsuOePTc1EKJo8=:eyJkZWFkbGluZSI6MTY0NzgyODY3NCwic2NvcGUiOiJ5b3VyLWJ1Y2tldC1uYW1lIn0=".parse()?;
let access_key = upload_token.access_key(Default::default())?;
let bucket_name = upload_token.bucket_name(Default::default())?;
let upload_policy = upload_token.policy(Default::default())?;

Re-exports

Modules

  • 将所有 Trait 全部重新导出,方便统一导入

Structs

Enums

Traits

Type Aliases