[英]s3 javascript create bucket
I have cognitoIdentityPool code for my credentials and use amazon aws javascript in browser. 我的凭据具有cognitoIdentityPool代码,并在浏览器中使用Amazon AWS JavaScript。 I can do everything with javascript in browser except createBucket.
除了createBucket,我可以在浏览器中使用javascript进行所有操作。 My js code in html is look like;
我在html中的js代码看起来像;
var s3 = new AWS.S3();
var params = {
Bucket: 'myuniquebucketname',
ACL: 'private',
CreateBucketConfiguration: {
LocationConstraint: 'us-east-1'
},
GrantFullControl: 'STRING_VALUE',
GrantRead: 'STRING_VALUE',
GrantReadACP: 'STRING_VALUE',
GrantWrite: 'STRING_VALUE',
GrantWriteACP: 'STRING_VALUE'
};
s3.createBucket(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
First of all, if I give full control, what can I write for STRING_VALUE in GrantFullControl: 'STRING_VALUE',
By the way, its not necessary to set up GrantRead, GrantWrite or other grant lines for working script. 首先,如果我有完全的控制权,我可以在
GrantFullControl: 'STRING_VALUE',
为STRING_VALUE编写什么GrantFullControl: 'STRING_VALUE',
顺便说一句,不必为工作脚本设置GrantRead,GrantWrite或其他授权行。 It gives cross origin CORS error. 它给出了跨原点的CORS错误。 However I can delete bucket, upload file to buckets etc. clearly without CORS error.
但是我可以删除存储桶,将文件上传到存储桶等,而不会出现CORS错误。 Any idea please.
任何想法,请。
I believe this is the expected behavior. 我相信这是预期的行为。 Assuming that your page is served from mybucket.s3.amazonaws.com, then uploading a file via putObject results in an HTTP request to mybucket.s3.amazonaws.com (the same domain) and is therefore OK but calling createBucket targets s3.amazonaws.com (a different domain) and therefore results in a CORS error.
假设您的网页是从mybucket.s3.amazonaws.com提供的,然后通过putObject上传文件会导致向mybucket.s3.amazonaws.com(相同的域)发出HTTP请求,因此可以,但是调用createBucket定位到s3.amazonaws .com(其他域),因此会导致CORS错误。 Similarly, if you call listBuckets then it will fail with a CORS error for the same reason.
同样,如果您调用listBuckets,由于相同的原因,它将失败并显示CORS错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.