如何解决s3 client.uploadFile挂起没有错误
我的凭证与AWS cli一起成功上载了s3文件,凭证与作为静态站点的存储桶上的管理员用户相关联。 更新:下载按预期运行。由于某种原因,节点“ s3”包失败,但未显示任何错误,它仅记录:
progress 0 4561 4561
progress 0 4561 4561
...
unable to upload: RequestTimeout: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
at Request.extractError (/Users/../node_modules/aws-sdk/lib/services/s3.js:700:35)
at Request.callListeners (/Users/../node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/../node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/../node_modules/aws-sdk/lib/request.js:688:14)
我不确定是什么问题?有什么见解吗?下面的代码是直接从s3软件包https://www.npmjs.com/package/s3
中获取的// RUNNING NODE 11.0 (due to un-updated dependencies in s3 or aws-sdk it must be under 11.15)
const { accessKeyId,secretAccessKey } = require('./tools/AWS.json')
const s3 = require('s3')
const AWS = require('aws-sdk')
const awsS3Client = new AWS.S3({
accessKeyId,secretAccessKey,signatureVersion: 'v4',region: 'us-east-2',})
const client = s3.createClient({
s3Client: awsS3Client,})
const liveBucket = 'my-bucket'
const params = {
localFile: 'out/404.html',s3Params: {
Bucket: liveBucket,Key: '404.html',},}
const uploader = client.uploadFile(params)
uploader.on('error',function(err) {
// never runs ...
console.error('unable to upload:',err.stack)
})
uploader.on('progress',function() {
// runs like 5 times before failing after a long wait
console.log('progress',uploader.progressMd5Amount,uploader.progressAmount,uploader.progressTotal)
})
uploader.on('end',function() {
// never runs ...
console.log('done uploading')
})
权限:
{
"Version": "2012-10-17","Statement": [
{
"Sid": "PublicReadGetObject","Effect": "Allow","Principal": "*","Action": "s3:GetObject","Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
解决方法
由于存储桶权限问题,看来您的上传文件被挂起。请尝试向您的存储桶添加以下权限:
- s3:PutObject
- s3:PutObjectTagging
- s3:ListBucketMultipartUploads
- s3:ListMultipartUploadParts
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。