React native 响应本机文件系统下载

React native 响应本机文件系统下载,react-native,asynchronous,download,filesystems,expo,React Native,Asynchronous,Download,Filesystems,Expo,我正在用react native编写一个应用程序,它必须允许用户将文档下载到他们的设备上,并且有一些问题 首先是守则。我想确保我已经正确地设置好了。我正在使用世博会的环境。以下是相关部分: import * as FileSystem from 'expo-file-system'; const Listitem = ({ item, setDownloading }) => { const { doc, // this is a filepath to the docum

我正在用react native编写一个应用程序,它必须允许用户将文档下载到他们的设备上,并且有一些问题

首先是守则。我想确保我已经正确地设置好了。我正在使用世博会的环境。以下是相关部分:

import * as FileSystem from 'expo-file-system';

const Listitem = ({ item, setDownloading }) => {

  const {
    doc, // this is a filepath to the document on a webserver 
    doc_title,
    title } = item;

  const downloadFile = async () => {
    setDownloading(true);
    console.log('fired');

    FileSystem.downloadAsync(
      doc,
      FileSystem.documentDirectory + doc_title
    )
      .then(({ uri }) => {
        setDownloading(false);
        console.log('Finished downloading to ', uri); // results are show below
      })
      .catch(error => {
        setDownloading(false);
        console.error(error);
      });
  }

  return !title ? null : (
    <View>
      {doc != '' &&
        <TouchableOpacity onPress={ downloadFile }>
            <Text>download file</Text>
        </TouchableOpacity>
      }
    </View>
}
在我的iPhone上,在世博会环境中:

Finished downloading to  file:///var/mobile/Containers/Data/Application/5F58DB37-FF66-4CAF-8520-A0D82C7B3EF3/Documents/ExponentExperienceData/%2540anonymous%252Fapp-name-34c241e6-2364-40cb-bd45-b8e8fcc0d87e/document_name.pptx
因此,我的问题是:

  • 我这样做对吗

  • 我在哪里可以找到下载的文件?因为我已经到处找过了(无论是在模拟器上还是在我的手机上),没有找到任何东西

  • 非常感谢你的帮助

    Finished downloading to  file:///var/mobile/Containers/Data/Application/5F58DB37-FF66-4CAF-8520-A0D82C7B3EF3/Documents/ExponentExperienceData/%2540anonymous%252Fapp-name-34c241e6-2364-40cb-bd45-b8e8fcc0d87e/document_name.pptx