我目前正在将我的项目从SDK v2升级到V3的过程中,我正在努力访问我上传到S3存储桶的文件的位置URL。
目前,以下实现无法访问location
,因为它不存在于AbortMultipartUploadCommandOutput
响应类型中。
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)
}
我一直在探索的另一个解决方案是使用PutObjectCommand
。
const command = new PutObjectCommand({
Bucket: BUCKET_NAME,
Key: `${path}/${fileName}`,
Body: fileContent,
ContentType: "text/csv"
})
一旦文件上传到S3上,有哪些可能的解决方案可以访问我的文件信息?