I try to download file from AWS S3, this file downloaded successfuly, but it isn't save in my disk, and I don't get any error.
<script>
import AWS from 'aws-sdk';
import FS from 'browserify-fs';
export default {
computed: {
s3Client() {
// Enter copied or downloaded access ID and secret key here
const ID = 'RANDOM_ID';
const SECRET = 'RANDOM_SECRET';
return new AWS.S3({
accessKeyId: ID,
secretAccessKey: SECRET
})
}
},
methods: {
downloadFile() {
const BUCKET_NAME = 'js-bucket'
const FILE_NAME = 'test.epub'
const params = {
Key: FILE_NAME,
Bucket: BUCKET_NAME
}
console.info("Try to download file : " + FILE_NAME + " from bucket: " + BUCKET_NAME)
this.isDownloading = true
this.s3Client.getObject(params)
.promise()
.then(data => {
FS.writeFile(FILE_NAME, data.Body, function (err) {
if (err) {
console.log(err.code, "-", err.message);
}
})
console.log('File downloaded successfully')
})
.catch(err => console.error(err))
}
}
}
</script>
In console I see my message about success save:File downloaded successfully. But it isn't right.