xxxxxxxxxx
result, err := uploader.Upload(context.TODO(), &s3.PutObjectInput{
Bucket: aws.String("my-bucket"),
Key: aws.String("my-object-key"),
Body: uploadFile,
})
output, err := u.upload(input)
if err != nil {
var mu manager.MultiUploadFailure
if errors.As(err, &mu) {
// Process error and its associated uploadID
fmt.Println("Error:", mu)
_ = mu.UploadID() // retrieve the associated UploadID
} else {
// Process error generically
fmt.Println("Error:", err.Error())
}
return
}
If an upload to Amazon S3 fails, by default, `Uploader` uses the Amazon S3 `AbortMultipartUpload` operation to remove the uploaded parts. This functionality ensures that failed uploads do not consume Amazon S3 storage.
You can set `LeavePartsOnError` to true so that the `Uploader` doesn’t delete successfully uploaded parts. This is useful for resuming partially completed uploads. To operate on uploaded parts, you must get the `UploadID` of the failed upload. The following example demonstrates how to use the `manager.MultiUploadFailure` error interface type to get the `UploadID`.