[英]Getting error while using the javascript Sdk for amazon s3 to Create bucket to my live repository
Getting error while using the javascript Sdk for amazon s3 to Create bucket to amazon This is the code that I am using in my javascript file 在使用Amazon S3的javascript SDK到Amazon创建存储桶时出现错误这是我在javascript文件中使用的代码
[$scope.creds = {
bucket: $rootScope.SIGNATURE_CREDS.bucket,
access_key: $rootScope.SIGNATURE_CREDS.access_key,
secret_key: $rootScope.SIGNATURE_CREDS.secret_key
}
AWS.config.update({ accessKeyId: $scope.creds.access_key, secretAccessKey: $scope.creds.secret_key });
AWS.config.region = 'us-east-1';
var params = {
Bucket:'AliNafees',
ACL: 'public-read '
};
var s3 = new AWS.S3({ params: { Bucket: $scope.creds.bucket, ACL: "public-read" } });
s3.createBucket(params, function(err, data) {
console.log(err, data);
});][1]
When you create a bucket, it has the CORS attribute. 创建存储桶时,它具有CORS属性。 Usually it is set by clicking it and then simply clicking save. 通常,通过单击它然后简单地单击保存来进行设置。 Try to set this value in your code, usually the default value of it is: 尝试在代码中设置此值,通常其默认值为:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.