简体   繁体   English

在本机反应中放大下载的文件位置

[英]Amplify downloaded files location in react native

I'm able to download a file from S3 in a react native app with AWS Amplify backend using the storage.get function.我可以使用storage.get function 在带有 AWS Amplify 后端的 react 本机应用程序中从 S3 下载文件。 However, not able to find where the downloaded files are stored?但是,无法找到下载文件的存储位置? How can we access the downloaded files content in react native?我们如何在 react native 中访问下载的文件内容? The Amplify documentation doesn't say where are the files downloaded by default. Amplify 文档没有说明默认下载的文件在哪里。

Answering my own question.回答我自己的问题。 Storage.get has an option to set download to true to download the files. Storage.get 可以选择将 download 设置为 true 以下载文件。 However, I was not able to find the location of the downloaded files.但是,我无法找到下载文件的位置。 Hence, I switched to getting the signed url first with storage.get by setting download to false and the use the axios to download the file using http get method by passing the signed url. Hence, I switched to getting the signed url first with storage.get by setting download to false and the use the axios to download the file using http get method by passing the signed url.

const signedURL = await Storage.get('test.json');
const response = await axios.get(signedURL);
console.debug('S3 data: ', response.data);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM