S3尝试从Android模拟器下载文件时返回403
我正在开发带有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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查您的模拟器日期和时间。签名取决于时间,因此您的仿真时间应该是正确的。
Check your emulator date and time. The signature is time dependent so your emulator time should be correct.
终于弄清楚了。我必须在后端配置LocalStack应该使用我的PC IP,并通过该IP访问模拟器上的文件。这样,获取请求就成功了。
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.