qiniu-uploader

Crates.ioqiniu-uploader
lib.rsqiniu-uploader
version
sourcesrc
created_at2024-08-03 16:40:08.85741
updated_at2024-10-05 06:24:40.539914
descriptionQiniu upload lib with progress bar
homepage
repositoryhttps://github.com/bujnlc8/qiniu-uploader
max_upload_size
id1324442
Cargo.toml error:TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(bujnlc8)

documentation

README

Crates.io qiniu-uploader

七牛文件上传

封装了七牛直传文件分片上传 v2 版,支持显示上传进度条,由indicatif提供支持.

分片上传的时候,支持设置分片大小和上传线程数量(基于 tokio::spawn)

使用

默认启用显示进度条

cargo add qiniu-uploader

也可以关闭显示进度条

cargo add qiniu-uploader --no-default-features

use mime::Mime;
use qiniu_uploader::{QiniuRegionEnum, QiniuUploader};
use tokio::fs;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let qiniu = QiniuUploader::new(
        "access_key",
        "secret_key",
        "bucket",
        Some(QiniuRegionEnum::Z0),
        false,
    );
    let file = fs::File::open("./Cargo.lock").await?;
    let file_size = file.metadata().await?.len() as usize;
    // 分片上传,支持设置分片大小或上传线程数量
    qiniu
        .clone()
        .part_upload_file(
            "test/Cargo.lock",
            file,
            file_size,
            Some(1024 * 1024 * 50), // 分片大小
            Some(10),               // 上传线程数量
            None,                   // 进度条样式
        )
        .await?;
    // 直传,文件大小应在1GB以内为宜
    let file = fs::File::open("./Cargo.lock").await?;
    qiniu
        .upload_file(
            "test/Cargo.lock.1",
            file,
            mime::APPLICATION_OCTET_STREAM,
            file_size,
            None,
        )
        .await?;
    Ok(())
}

更详细的参数见https://docs.rs/qiniu-uploader/

Commit count: 19

cargo fmt