放入可写存储桶:400

时间:2018-10-29 14:04:43

标签: javascript amazon-s3

在测试期间,我公开了我的存储桶(以后,用户将在此处上传其文件-Lambda将下载它们): s3 Permissions

我的CORS是:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

我的JS是:

input.onchange = function() {
    fetch('https://mybucketname.s3.amazonaws.com/', {
        'method': 'PUT',
        'body': this.files[0]
    })
}

但是来自S3的响应是400,没有说明。在PUT之前,我看到成功的选项。在documentation中,我仅看到一个必需的标头-Content-Length-并且浏览器将其添加。

1 个答案:

答案 0 :(得分:0)

URL!您必须指定文件名,如

https://mybucketname.s3.amazonaws.com/myfile.jpg

相关问题