【发布时间】:2013-04-13 19:33:09
【问题描述】:
下午好,
我正在尝试建立与我的 aws 产品 api 的连接,但是我不断收到 301 永久重定向错误,如下所示:
{ [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',
name: 'PermanentRedirect',
statusCode: 301,
retryable: false }
我用来连接API的代码如下:
var aws = require('aws-sdk');
//Setting up the AWS API
aws.config.update({
accessKeyId: 'KEY',
secretAccessKey: 'SECRET',
region: 'eu-west-1'
})
var s3 = new aws.S3();
s3.createBucket({Bucket: 'myBucket'}, function() {
var params = {Bucket: 'myBucket', Key: 'myKey', Body: 'Hello!'};
s3.putObject(params, function(err, data) {
if (err)
console.log(err)
else
console.log("Successfully uploaded data to myBucket/myKey");
});
});
如果我尝试使用不同的区域,例如 us-west-1,我会得到同样的错误。
我做错了什么?
提前非常感谢您!
【问题讨论】:
-
哦,好吧,那我该如何让它工作 - 或者有什么问题?
-
这里可能是显而易见的:跟随重定向。但是,您使用的 API 可能存在缺陷,它不遵循您的重定向。
-
哇!修复!问题是我没有在我的 S3 控制台中创建任何存储桶!还是谢谢老哥!
标签: javascript node.js amazon-web-services amazon-s3 http-status-code-301