我需要在 s3 存储桶中配置 CORS 我拥有的代码不是有效的 JSON [英] I need to configure CORS in s3 bucket the code I have isn't a valid JSON

查看:13
本文介绍了我需要在 s3 存储桶中配置 CORS 我拥有的代码不是有效的 JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的 s3 照片桶制作照片库.我流程的下一步是配置 CORS,但是当我使用提供的代码时,出现错误.有人可以解释一下我做错了什么或如何将代码更改为有效的 JSON?

感谢您的帮助,不胜感激.对此很陌生.

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photos-view.html

跨域资源共享 (CORS)用 JSON 编写的 CORS 配置为加载在一个域中的客户端 Web 应用程序与不同域中的资源进行交互定义了一种方式.了解更多CORS 配置必须以有效的 JSON 编写.API 响应预期 params.CORSConfiguration.CORSRules 是一个数组

<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><CORSRule><AllowedOrigin>*</AllowedOrigin><AllowedMethod>GET</AllowedMethod><AllowedMethod>HEAD</AllowedMethod><AllowedHeader>*</AllowedHeader></CORSRule></CORSConfiguration>

解决方案

复制粘贴示例

<预><代码>[{允许的标题":[*"],允许的方法":[获取",头"],允许的起源":[*"],ExposeHeaders":[]}]

I am trying to make a photo gallery from my s3 photo bucket. the next step in my process is to configure CORS but when I use the code provided I get an error. Can someone please explain what I am doing wrong or how to change the code to valid JSON?

thanks for your help, its appreciated. Very new to this.

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photos-view.html

Cross-origin resource sharing (CORS) The CORS configuration, written in JSON, defines a way for client web applications that are loaded in one domain to interact with resources in a different domain. Learn more 

 The CORS configuration must be written in valid JSON. API response Expected params.CORSConfiguration.CORSRules to be an Array

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

解决方案

Copy paste example

[
 {
    "AllowedHeaders": [
        "*"
    ],
    "AllowedMethods": [
        "GET",
        "HEAD"
    ],
    "AllowedOrigins": [
        "*"
    ],
    "ExposeHeaders": []
 }
]

这篇关于我需要在 s3 存储桶中配置 CORS 我拥有的代码不是有效的 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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