gpt4 book ai didi

reactjs - 如何将 json 文件从 s3 返回到特定的 url,但仅返回该 url

转载 作者:行者123 更新时间:2023-12-03 13:42:01 25 4
gpt4 key购买 nike

我有一个已在其他地方设置的特殊 URL,并且无法更改。

mydomain.com/discountCards

每当服务器向 mydomain.com/discountCards 发送提取调用时,我都需要从我的 s3 存储桶返回一个 JSON

问题是:

我正在 mydomain.com 上使用带有 React-Router 的 React 应用程序。因此,访问 mydomain.com/discountCards 会显示一个白色 react 页面(因为该网址上没有任何内容)

我正在尝试设置 Cloudfront 以直接链接到有效的 s3 JSON 文件 - 但问题是:

它仅适用于 mydomain.com/discountCards.json,不适用于 mydomain.com/discountCards

所以...现在我的 s3 存储桶有一个名为discountCards.json 的文件 - 但我需要它是没有“.json”的discountCard。

还是别的什么?

如何使用 AWS s3、cloudfront 和路由 53 从我的 s3 返回此 .json 作为特定域?

就像我说的,我已经将所有设置都设置为 cloudfront 指向我的 s3 文件,但它要求我在 URL 中包含文件扩展名(我不能这样做,该 URL 已经在 mydomain.com/上被锁定)折扣卡不是discountCards.json)

这样其他网站和应用程序就可以获取该 URL 并获取返回的 json。还有其他方法可以实现这一目标吗?

最佳答案

So.... right now my s3 bucket has a file called discountCards.json - but I need that to be discountCard without the ".json"

将文件discountCard.json保存为不带.json扩展名的discountCard。见下图

enter image description here

然后在元数据下的属性上将 content-type 添加到 application/json 参见下图

enter image description here

现在可以通过此 url https://s3.amazonaws.com/stackkkover/discountCards 访问存储桶

这个答案的灵感来自这篇文章https://stackoverflow.com/a/27046083/3521330

希望这个回答对您有所帮助。谢谢。

关于reactjs - 如何将 json 文件从 s3 返回到特定的 url,但仅返回该 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56087853/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com