D
D
Denis2020-09-09 17:18:56
React Native
Denis, 2020-09-09 17:18:56

What is the best way to open downloaded React Native Expo file?

I don’t know, unfortunately or fortunately, but for now we use Expo
And it is advisable not to cut it out yet.
I'm trying to implement a function to open a file that was downloaded through this function.

const downloadFile = async (url) => {
    let path = url.split('/');
    const file_name = path[path.length - 1];
    FileSystem.downloadAsync(url, FileSystem.documentDirectory + file_name)
      .then(({ uri }) => {
        console.log('Finished downloading to ', uri);
        setSystemUri(uri);
        MediaLibrary.createAssetAsync(uri).then((asset) => {
          //console.log('asset', asset);
          MediaLibrary.createAlbumAsync('MyFolder', asset)
            .then((asset) => {
              //alert('Success download');
              //console.log(asset)
            })
            .catch((error) => {});
        });
      })
      .catch((error) => {
        console.error(error);
      });
  };


Gives me a function like this path file:///
On Android, as expected, everything works. I can go to the folder that I created, or if a photo / video was downloaded, then through the gallery.
But on iOS it's a problem. The folder itself is not visible in the system and I can’t open the file in any way.
Is it possible to open the file on both platforms after downloading? There is an expo-intent-launcher on Android but it doesn't work on iPhone.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question