gpt4 book ai didi

node.js - 使用 multer -s3 亚马逊服务器图片上传错误访问被拒绝

转载 作者:搜寻专家 更新时间:2023-10-31 22:51:54 26 4
gpt4 key购买 nike

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)

最佳答案

即使我也遇到了同样的问题,但我已经解决了。

对我来说,这个问题的原因是我一直在将 acl(访问控制列表)键 acl: 'public-read' 传递给 multerS3 对象参数。

ACL key 区分大小写,而不是使用 acl: 'public-read' 使用 ACL: 'public-read' 工作正常。

如果您没有在 multerS3 对象参数中传递 ACL 属性也可以。

如果未指定 ACL,则默认使用 ACL: 'private'

存储文件

AWS 支持以下选项:

ACL:私有(private) |公众阅读 |公共(public)读写 | aws-exec-读 |认证阅读 |桶拥有者阅读 |桶拥有者完全控制

带有 acl 的 multerS3(访问被拒绝):

var upload = multer({
storage: multerS3({
s3: s3,
acl: 'public-read',
bucket: BucketName,
key: function (req, file, cb) {
cb(null, new Date().toISOString() + '-' + file.originalname);
}
})
});

带有 ACL 的 multerS3(工作正常):

var upload = multer({
storage: multerS3({
s3: s3,
ACL: 'public-read',
bucket: BucketName,
key: function (req, file, cb) {
cb(null, new Date().toISOString() + '-' + file.originalname);
}
})
});

关于node.js - 使用 multer -s3 亚马逊服务器图片上传错误访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38769366/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com