Every growing business is now days moving to AWS & GCP.
Here we need to configure AWS s3 instance.
first let’s install & import it.
npm install aws-sdk
const AWS = require(‘aws-sdk');
We need to configure it, for our service, try to put this a common place so that entire app can use it, wherever required.
const s3Bucket = new AWS.S3({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey:process.env.AWS_ACCESS_KEY_SECRET
});
we can get this access key & secret using aws console.
const params = {
Bucket: process.env.AWS_BUCKET_NAME,
Key: path where we need to store the file on aws bucket
,
Body: fileData,
ACL:’public-read’
}
Thanks !!