Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大文件上传失败 #18

Open
molast opened this issue Oct 20, 2022 · 1 comment
Open

大文件上传失败 #18

molast opened this issue Oct 20, 2022 · 1 comment

Comments

@molast
Copy link

molast commented Oct 20, 2022

服务器直传方式, 上传20M的文件时传不上去,传输几兆的文件能传成功

let access_key = "xxx";
    let secret_key = "xxx";
    let bucket_name = "xxx";

    let credential = Credential::new(access_key, secret_key);
    let upload_manager = UploadManager::builder(UploadTokenSigner::new_credential_provider(
        credential,
        bucket_name,
        Duration::from_secs(3600),
    ))
    .build();
    let mut auto_uploader: AutoUploader = {
        let builder = AutoUploader::builder(upload_manager);
        builder.build()
    };

    auto_uploader.on_upload_progress(|transfer| {
        let transferred_bytes = transfer.transferred_bytes();
        if let Some(total_bytes) = transfer.total_bytes() {
            println!(
                "{} / {} => {}%",
                transferred_bytes,
                total_bytes,
                transferred_bytes as f64 * 100f64 / total_bytes as f64
            );
        } else {
            println!("{}", transferred_bytes);
        }
        Ok(())
    });

    let params = AutoUploaderObjectParams::builder()
        .object_name(object_name)
        .file_name(object_name)
        .build();

    let value = auto_uploader.async_upload_path(filepath, params).await;

@bachue
Copy link
Collaborator

bachue commented Oct 20, 2022

@aiminchen 传不上去是什么错误呢?是否有详细的日志?可以用 env_logger 来获取

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants