Struggling with saving images directly to AWS S3 using AWS S3.
Attempted to add the AWS package as a plugin without success.
In the nuxt.config.js
file, I have:
plugins: [
...
'~plugins/S3.js'
],
In the plugins/s3.js
file:
import vue from "vue"
import S3 from "aws-s3";
vue.use(S3)
When trying to use it in my code:
const S3Client = new S3(config)
S3Client
.uploadFile(file, this.getRandomName(10))
.then(data => {
console.log(data)
})
.catch(err => {
console.log(err)
})
Encountering the error:
multiplephotoupload.vue?7624:110 Uncaught (in promise) ReferenceError: S3 is not defined
However, when directly importing into the component file, it works:
import S3 from "aws-s3";