Expand description

qiniu-upload-manager

七牛上传管理

基于 qiniu-apis 提供针对七牛对象的上传功能 (同时提供阻塞客户端和异步客户端,异步客户端则需要启用 async 功能)。

功能描述

async

启用异步接口。

ureq

导入 qiniu-ureq 作为 HTTP 客户端。

isahc

导入 qiniu-isahc 作为 HTTP 客户端。

reqwest

导入 qiniu-reqwest 作为 HTTP 客户端。

c_ares

启用 c-ares 库作为 DNS 解析器。

trust_dns

启用 trust-dns 库作为 DNS 解析器。

dns-over-https

启用 trust-dns 库作为 DNS 解析器,并使用 DOH 协议。

dns-over-tls

启用 trust-dns 库作为 DNS 解析器,并使用 DOT 协议。

代码示例

用自动上传器上传文件
阻塞代码示例
use qiniu_upload_manager::{
    apis::credential::Credential, AutoUploader, AutoUploaderObjectParams, UploadManager,
    UploadTokenSigner,
};
use std::time::Duration;

let bucket_name = "test-bucket";
let object_name = "test-object";
let upload_manager = UploadManager::builder(UploadTokenSigner::new_credential_provider(
    Credential::new("abcdefghklmnopq", "1234567890"),
    bucket_name,
    Duration::from_secs(3600),
))
.build();
let params = AutoUploaderObjectParams::builder().object_name(object_name).file_name(object_name).build();
let mut uploader: AutoUploader = upload_manager.auto_uploader();
uploader.upload_path("/home/qiniu/test.png", params)?;
异步代码示例
use qiniu_upload_manager::{
    apis::credential::Credential, AutoUploader, AutoUploaderObjectParams, UploadManager,
    UploadTokenSigner,
};
use std::time::Duration;

let bucket_name = "test-bucket";
let object_name = "test-object";
let upload_manager = UploadManager::builder(UploadTokenSigner::new_credential_provider(
    Credential::new("abcdefghklmnopq", "1234567890"),
    bucket_name,
    Duration::from_secs(3600),
))
.build();
let params = AutoUploaderObjectParams::builder().object_name(object_name).file_name(object_name).build();
let mut uploader: AutoUploader = upload_manager.auto_uploader();
uploader.async_upload_path("/home/qiniu/test.png", params).await?;

Re-exports

Modules

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

Structs

Enums

Traits