React native React native FS copyFile()从未解析

React native React native FS copyFile()从未解析,react-native,react-native-fs,React Native,React Native Fs,我必须将使用react-native document picker拾取的文件复制到我的应用程序的临时路径,然后读取该文件,但当它到达时,等待react-NativeFS.copyFile(realPath,tempPath)行,它永远不会解析。这是密码 searchAndReadFiles = async () => { try { const fileSelected = await DocumentPicker.pick ({ type: Docum

我必须将使用react-native document picker拾取的文件复制到我的应用程序的临时路径,然后读取该文件,但当它到达
时,等待react-NativeFS.copyFile(realPath,tempPath)行,它永远不会解析。这是密码


searchAndReadFiles = async () => {
  try { 
     const fileSelected = await DocumentPicker.pick ({
        type: DocumentPicker.types.plainText,
     }); 
     const decodedURI = decodeURIComponent(fileSelected.uri);
     const split = decodedURI.split('/');
     const name = split.pop();
     const inbox = split.pop();
     const realPath = `${ReactNativeFS.TemporaryDirectoryPath}/${name}`;
     const tempPath = `${ReactNativeFS.ExternalStorageDirectoryPath}/${fileSelected.name}`;
     await ReactNativeFS.copyFile(realPath, tempPath);
     const fileRead = await ReactNativeFS.readFile(tempPath);
  } catch (err) {   
     console.warn(err);
  }
}

所以我发现copyFile()方法本身解码路径,我只是将编码的uri(与我从document picker pick()方法接收的方式相同)作为参数传递,它工作得很好,谢谢

searchAndReadFiles = async () => {
        try { 
            const fileSelected = await DocumentPicker.pick ({
                type: DocumentPicker.types.allFiles, 
            }); 
            const destPath = `${ReactNativeFS.CachesDirectoryPath}/${fileSelected.name}`;
            await ReactNativeFS.copyFile(fileSelected.uri, destPath);
            ...