How to get totalPartNumbers
and totalBytes
for upload in v3?
#5165
-
In SDK v2, I used the s3Client to directly call Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
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;
});
const uploadResponse = await uploader.done();
resolve({
uploadDetail,
uploadResponse
})
});
console.log(result) Please let me know if that helps! Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi @jirimoravcik, with v3 you can use the httpUploadProgress event as follow: