var s3 = require('s3');
var client = s3.createClient({
maxAsyncS3: 20,
s3RetryCount: 3,
s3RetryDelay: 1000,
multipartUploadThreshold: 20971520,
multipartUploadSize: 15728640,
s3Options: {
accessKeyId: "ABC",
secretAccessKey: "XYZ",
region: " us-east-2",
endpoint: 's3-us-east-2.amazonaws.com',
ACL: ''
}
});
var uploadParams = {
localFile: '/home/onur/Desktop/cwiz.jpg',
s3Params: {
Bucket: 'cwizz',
Key: '', // How can I found bucked key ?
}
};
var uploader = client.uploadFile(uploadParams);
uploader.on('error', function(err) {
return console.error('unable to upload:', err, err.stack);
});
uploader.on('end', function() {
console.log("done uploading");
});
我怎样才能找到反键?
无法上传:{InvalidRequest:不支持您提供的授权机制。请使用AWS4-HMAC-SHA256。
答案 0 :(得分:0)
Bucket key是存储桶中您希望上传文件的路径。例如以下内容将您的图像上传到cwizz存储桶中的images / cwiz.jpg。此外,您不需要在s3Options对象中使用区域,端点和ACL。
var s3 = require('s3');
var client = s3.createClient({
maxAsyncS3: 20,
s3RetryCount: 3,
s3RetryDelay: 1000,
multipartUploadThreshold: 20971520,
multipartUploadSize: 15728640,
s3Options: {
accessKeyId: "ABC",
secretAccessKey: "XYZ"
}
});
var uploadParams = {
localFile: '/home/onur/Desktop/cwiz.jpg',
s3Params: {
Bucket: 'cwizz',
Key: 'images/cwiz.jpg',
}
};
var uploader = client.uploadFile(uploadParams);
uploader.on('error', function(err) {
return console.error('unable to upload:', err, err.stack);
});
uploader.on('end', function() {
console.log("done uploading");
});