Skip to content

How to get totalPartNumbers and totalBytes for upload in v3? #5165

Discussion options

You must be logged in to vote

Hi @jirimoravcik, with v3 you can use the httpUploadProgress event as follow:

import { Upload } from "@aws-sdk/lib-storage";
import { S3Client } from "@aws-sdk/client-s3";

const client = new S3Client({
    region: "us-east-2"
});
const uploader = new Upload({
    client,
    params: {
        Bucket: process.env.TEST_BUCKET,
        Key: process.env.TEST_KEY,
        Body: "#".repeat(1024 * 1024 * 10)
    }
});
const result = await new Promise(async (resolve) => {
    const uploadDetail = {
        totalParts: 0,
        totalBytes: 0
    };
    uploader.on('httpUploadProgress', (event) => {
        uploadDetail.totalParts = event.part;
        uploadDetail.totalBytes = event.total;
    });

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jirimoravcik
Comment options

Answer selected by yenfryherrerafeliz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
2 participants