I want to use it in VueJS as below code via the URL of a file that is made public in AWS S3 or Google Drive.
...
const file = AWS S3 or Google Drive File URL
...
How can this be done?
I want to use it in VueJS as below code via the URL of a file that is made public in AWS S3 or Google Drive.
...
const file = AWS S3 or Google Drive File URL
...
How can this be done?
You need to make a Blob.
const response = await this.$axios.get(`documents?s3-key=${s3Key}`)
const awsS3Response = await axios.get(response.data, { responseType: 'blob' })
const blob = new Blob([awsS3Response.data])
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = s3Key
link.click()
URL.revokeObjectURL(link.href)
response.data
is a signed url
This is how I created the signed url in my API.
const s3 = new AWS.S3({ apiVersion: '2006-03-01' })
async function getDocument({ s3Key }) {
return s3.getSignedUrl('getObject', {
Bucket: 'lqdc2documents',
Key: s3Key,
Expires: 60,
})
}