How to get totalPartNumbers
and totalBytes
for upload in v3?
#5165
Answered
by
yenfryherrerafeliz
jirimoravcik
asked this question in
Q&A
-
In SDK v2, I used the s3Client to directly call Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
yenfryherrerafeliz
Sep 13, 2023
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.
1 reply
Answer selected by
yenfryherrerafeliz
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @jirimoravcik, with v3 you can use the httpUploadProgress event as follow: