我正在尝试使用来自法兰克福或都柏林实例的s3cmd从ec2上传文件到s3:
s3cmd put -r folder s3://bucket
但是,我得到了:
ERROR: S3 error: 400 (InvalidRequest): The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
我看到this question建议通过执行以下操作将配置设置为V4:
signatureVersion: 'v4'
如何使用s3cmd命令执行此操作?
答案 0 :(得分:3)
您必须使用最新版本1.6.1
只需按以下方式或您可能想要使用的任何其他方式升级s3cmd。
pip install --upgrade
答案 1 :(得分:-1)
我有同样的问题。地区是亚太地区(孟买)。其实际区域为ap-south-1。这是链接 http://docs.aws.amazon.com/general/latest/gr/rande.html 还使用cmd配置AWSCLI aws configure set default.s3.signature_version s3v4 这是链接 http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html
这里有完整的workCode
var express = require('express');
var app = express();
var http = require('http').Server(app);
var fs = require('fs');
var aws = require('aws-sdk');
var S3FS = require('s3fs');
var s3fsImpl = new S3FS('ipxstorage/products', { accessKeyId:'Use your accesskey', secretAccesskey:'use your sck', region:'ap-south-1'});
var multiparty = require('connect-multiparty');
var multipartyMiddleware = multiparty();
aws.config.update({ signatureVersion:'v4'});
app.use(express.static(__dirname + '/public'));
app.set('views', __dirname+'/public/');
app.engine('html', require('ejs').renderFile);
app.use(multipartyMiddleware);
app.post('/upload', function(req, res){
console.log(req.files.file);
var file = req.files.file;
var stream = fs.createReadStream(file.path);
return s3fsImpl.writeFile(file.originalFilename, stream).then( function(){
console.log('File Saved...');
res.redirect('/')
});
});
<form action="upload" method="POST" enctype="multipart/form-data">
<div class="file-field input-field">
<div class="btn"><span>Browse File</span><input name="file" type="file"></div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
</div>
<button class="btn" type="Submit">Submit</button>
</form>