I am trying to upload images to AWS but because of the Migrating to the new build system it is not working anymore
import { Upload } from "@aws-sdk/lib-storage";
import { S3Client } from "@aws-sdk/client-s3";
const parallelUploads3 = new Upload({
client: new S3Client({}),
params: { Bucket, Key, Body },
});
parallelUploads3.on("httpUploadProgress", (progress) => {
console.log(progress);
});
parallelUploads3.done().then(
(data) => {
console.log(data)
},
(err: any) => {
console.log(err)
},
);
and i get this Error
TypeError: Cannot read properties of undefined (reading 'done')
at getChunkStream.js:5:5
at Generator.next (<anonymous>)
at resume (chunk-CDW57LCT.js?v=b9e9dd30:100:27)
at chunk-CDW57LCT.js?v=b9e9dd30:106:63
at new ZoneAwarePromise (zone.js:1425:21)
at it.<computed> [as next] (chunk-CDW57LCT.js?v=b9e9dd30:106:38)
at Upload.<anonymous> (Upload.js:130:9)
at Generator.next (<anonymous>)
at chunk-CDW57LCT.js?v=b9e9dd30:90:61
at new ZoneAwarePromise (zone.js:1425:21)
I expect the Migrating should have no effect on the app
i'm searching for the solution as well. but if your file is not large (less than 2G) based on my test, you can try transform the file to uint8Array first as a workaround
const arrayBuffer = await file.arrayBuffer();
const uint8Array = new Uint8Array(arrayBuffer);
const upload = new Upload({
client: s3Client,
params: { Bucket: bucket, Key: path, Body: uint8Array },
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With