I'm using the aws-sdk
to upload files to s3. I'm configuring my credentials with
aws.config.update({
accessKeyId: aws.config.credentials.accessKeyId,
secretAccessKey: aws.config.credentials.secretAccessKey,
region: 'us-east-1'
});
Then uploading with multer-s3
:
const s3 = new aws.S3();
const upload = multer({
storage: multerS3({
s3: s3,
bucket: 'my-bucket-v1',
acl: 'public-read',
contentType: multerS3.AUTO_CONTENT_TYPE,
key: function (req, file, cb) {
const today = new Date();
cb(null, file.originalname)
console.log("file\n", file);
}
})
}).array('upl', 1);
router.post('/api/upload', (req, res, next) => {
upload(req, res, err => {
if (err) return console.log("err\n", err);
res.status(201).send();
})
});
The error I keep getting is with my Access Key Id: "The AWS Access Key Id you provided does not exist in our records."
I've created multiple new access keys in my aws account, but nothing works. I'm using root user access keys (I tried an IAM user, and it still didn't work).
I also logged my aws credentials in my node server (console.log(s3)
), and it matches what's in my aws security credentials.
How do I properly configure my aws credentials to upload to s3?