我在我的公司使用ceph服务与空区域,所以我只能创建没有区域的s3连接。
aws-js-sdk会将区域指定为us-east-1
,我该如何忽略它?
它会显示getaddrinfo ENOTFOUND...
;
const AWS = require('aws-sdk');
const getS3Instance = () => new AWS.S3({
accessKeyId: 'xxx',
secretAccessKey: 'xxx',
endpoint: `...local`,
sslEnabled: false,
region: ''
});
try {
const s3 = getS3Instance();
const creatBucketRes = await s3.createBucket({ Bucket: `bucket-test` }).promise();
} catch(err) {
console.log(err);
}
答案 0 :(得分:2)
您需要设置存储桶所在的区域,
AWS.config.update({region: 'ap-northeast-2 '});
参考:
http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-region.html