AccessDenied: Access Denied
at Request.extractError (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/services/s3.js:524:35)
at Request.callListeners (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/request.js:615:14)
at Request.transition (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/request.js:617:12)
at Request.callListeners (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/request.js:615:14)
at Request.transition (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/home/cricket_game/node_modules/multer-s3/node_modules/s3fs/node_modules/aws-sdk/lib/request.js:38:9)
Even I was facing the same issue and I got it resolved.
For me the cause for this issue was I have been passing acl (Access control lists) key acl: 'public-read' to the multerS3 object params.
ACL key is case sensitive, instead of using acl: 'public-read'
using ACL: 'public-read'
worked fine.
Its ok if you didn't pass the ACL property in multerS3 object params.
If ACL not specified, then default is to store the file with ACL: 'private'
AWS supports the following options:
ACL: private | public-read | public-read-write | aws-exec-read | authenticated-read | bucket-owner-read | bucket-owner-full-control
multerS3 with acl (Access denied):
var upload = multer({
storage: multerS3({
s3: s3,
acl: 'public-read',
bucket: BucketName,
key: function (req, file, cb) {
cb(null, new Date().toISOString() + '-' + file.originalname);
}
})
});
multerS3 with ACL (Works fine):
var upload = multer({
storage: multerS3({
s3: s3,
ACL: 'public-read',
bucket: BucketName,
key: function (req, file, cb) {
cb(null, new Date().toISOString() + '-' + file.originalname);
}
})
});
I solved this issue by going to my
S3
Account inAWS
Website and givefull access
to the public underPermissions
tab. (
By the way it's not recommended as AWS said but it's the only way I found so that I get it done)
You need to create the following policy using IAM:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::your-bucket-name-here/*"
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With