S3尝试从Android模拟器下载文件时返回403

发布于 2025-02-12 04:58:04 字数 321 浏览 2 评论 0原文

我正在开发带有React Antial的Android应用程序,并且我遇到了S3问题。我正在模拟器上运行该应用程序,并尝试通过LocalStack的预设URL下载文件。我已经尝试使用RNF和RNFetchBlob做到这一点,它们都无法使用。使用两种液体,S3给出了此消息:

预先签名计算失败:<响应[403]>

我将我的请求发送到10.0.2.2:4566,而不是127.0.0.1:4566,因为该应用程序无法连接到后者(因为它在模拟器上运行)。

我可以通过浏览器访问URL,但是我无法在模拟器上使用它。我想念什么?

I'm developing an Android app with React Native and I have ran into a problem with S3. I'm running the app on an emulator, and trying to download a file through a presigned URL from localstack. I've tried to do so with RNFS and RNFetchBlob, none of them worked. With both libs, S3 gives this message:

Presign signature calculation failed: <Response [403]>

I'm sending my request to 10.0.2.2:4566 instead of 127.0.0.1:4566, because the app can't connect to the latter (because it runs on an emulator).

I can access the URL through my browser, but I can't make it work on the emulator. What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

命硬 2025-02-19 04:58:04

检查您的模拟器日期和时间。签名取决于时间,因此您的仿真时间应该是正确的。

Check your emulator date and time. The signature is time dependent so your emulator time should be correct.

寒尘 2025-02-19 04:58:04

终于弄清楚了。我必须在后端配置LocalStack应该使用我的PC IP,并通过该IP访问模拟器上的文件。这样,获取请求就成功了。

# AWS - localstack
aws.endpoint.url = http://192._._._:4566

Finally figured it out. I had to configure on the backend that localstack should use my PC's IP, and access the files on the Emulator through that. This way the GET request is successful.

# AWS - localstack
aws.endpoint.url = http://192._._._:4566
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文