Is there a way to abort an upload without raising an error Upload aborted.
when calling upload.abort()
?
import { PutObjectCommandInput, S3Client } from '@aws-sdk/client-s3';
import { Progress, Upload } from "@aws-sdk/lib-storage";
const uploadParams: PutObjectCommandInput = {
Bucket: 'my-bucket',
Key: 'my-file',
Body: file,
};
const upload: Upload = new Upload({
client: s3Client,
params: uploadParams,
});
// abort after 3 seconds
setTimeout(() => upload.abort(), 3000);
// start upload
upload.done();
I have attempted to handle the promise rejection:
upload.abort().then().catch(() => {
// ...
})
And also tried using try-catch block:
try {
upload.abort().then().catch(() => {
// ...
})
} catch () {
// ...
}