无法更新AWS S3 CORS政策 [英] Unable to update AWS S3 CORS POLICY

查看:64
本文介绍了无法更新AWS S3 CORS政策的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改我的AWS S3存储桶CORS策略,以允许将我的ReactJS的文件上传到AWS S3,但是我不断收到以下API响应:

I needed to change my AWS S3 bucket CORS policy to enable the upload of files for my ReactJS to AWS S3, but I keep getting this API response:

期望params.CORSConfiguration.CORSRules成为数组.

Expected params.CORSConfiguration.CORSRules to be an Array.

我现在很茫然.有人可以帮忙吗?

I am at a loss right now. Can anyone help?

推荐答案

我不确定这是否有帮助.最近,我遇到了同样的问题,而且似乎AWS对我们定义CORS配置的方式进行了一些更改.例如,如果您过去希望在S3存储桶中允许某些方法,则必须在编辑器上执行以下操作:

I'm not sure if this helps. I ran into this same problem recently and it seems like AWS made some changes with how we define our CORS configurations. For example, if you want to allow certain Methods on your S3 bucket in the past you have to do something like this on the editor:

<CORSConfiguration>
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>HEAD</AllowedMethod>
    <AllowedMethod>DELETE</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>

下面的配置与顶部的配置等效,但是采用数组的形式.

The config below is equivalent to the one on the top but takes the form of an array.

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "PUT",
            "POST",
            "HEAD",
            "DELETE"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]

让我知道这是否有帮助.谢谢!

Let me know if this helps. Thank you!

这篇关于无法更新AWS S3 CORS政策的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆