我从昨天开始就遇到这个问题,一直找不到解决方案。
我正在尝试将某些内容发送到我的 S3 存储桶,但是当我尝试时,此消息出现在我的控制台中:
{ [CredentialsError: Missing credentials in config]
message: 'Missing credentials in config',
code: 'CredentialsError',
errno: 'Unknown system errno 64',
syscall: 'connect',
time: Thu Oct 09 2014 14:03:56 GMT-0300 (BRT),
originalError:
{ message: 'Could not load credentials from any providers',
code: 'CredentialsError',
errno: 'Unknown system errno 64',
syscall: 'connect',
time: Thu Oct 09 2014 14:03:56 GMT-0300 (BRT),
originalError:
{ code: 'Unknown system errno 64',
errno: 'Unknown system errno 64',
syscall: 'connect',
message: 'connect Unknown system errno 64' } } }
这是我的代码:
var s3 = new AWS.S3();
AWS.config.loadFromPath('./AwsConfig.json');
s3.putObject(params, function(err) {
if(err) {
console.log(err);
}
else {
console.log("Succes");
}
});
凭证是正确的。有谁知道会是什么?我已经搜索过,但没有找到任何解决方案。
我的凭据(假的):
{
"accessKeyId": "BLALBLALBLALLBLALB",
"secretAccessKey": "BLABLALBLALBLALBLLALBLALLBLALB",
"region": "sa-east-1",
"apiVersions": {
"s3": "2006-03-01",
"ses": "2010-12-01"
}
}
EDIT:
如需帮助,所有代码:
var fs = require('fs');
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
AWS.config.loadFromPath('./MYPATH.json'); //this is my path to the aws credentials.
var params = {
Bucket: 'testing-dev-2222',
Key: file,
Body: fs.createReadStream(file)
};
s3.putObject(params, function(err) {
if(err) {
console.log(err);
}
else {
console.log("Success");
}
});
New err:
Error uploading data: { [PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.]
message: 'The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.',
code: 'PermanentRedirect',
time: Thu Oct 09 2014 14:50:02 GMT-0300 (BRT),
statusCode: 301,
retryable: false }