javascript – Access Location when uploading File to AWS S3 using @aws-sdk/lib-storage
I’m currently in the process of upgrading my project from SDK v2 to V3 and I’m struggling to access the location URL of the file I’m uploading to my S3 bucket.
Currently the below implementation is unable to access location since it does not exist within the AbortMultipartUploadCommandOutput response type.
try {
const x = new Upload({
client: new S3Client({ region: "us-east-2" }),
params: {
Bucket: BUCKET_NAME,
Key: filename.toString(),
Body: buffer
}
})
const response = await x.done()
const locationUrl = response.location
return locationUrl
} catch (error) {
console.log(error)
}
Another solution I’ve been exploring is using PutObjectCommand.
const command = new PutObjectCommand({
Bucket: BUCKET_NAME,
Key: `${path}/${fileName}`,
Body: fileContent,
ContentType: "text/csv"
})
What are the possible solutions to gaining access to my file’s information once it has been uploaded onto S3?
Read more here: Source link
