Downloading a file from expo react-native problem

Viewed 453

So in the following snipet everything works fine, problem is the FakeVaultDownloads folder is created inside the pictures folder in the devices storage. Is there something else I can use to create this folder inside the downloads folder? Issues is I am also downloading other file types like pdfs and txt documents and I don’t want those inside the pictures folder it doesn’t make sense those to be there, so I am trying to save them to a universal folder and not inside the pictures folder. Thanks for reading and sorry if I posted this in the wrong category any help is greatly appreciated.

 let downloadedFile = await FileSystem.downloadAsync(res.data.url, `${FileSystem.documentDirectory}${res.data.name}`);
            MediaLibrary.requestPermissionsAsync().then( async (res) => {
              const asset = await  MediaLibrary.createAssetAsync(downloadedFile.uri);
              const album = await MediaLibrary.getAlbumAsync('Download');
              if (album == null) {
                await MediaLibrary.createAlbumAsync('Download', asset, false);
                alert("File was downloaded to the Download folder ")
              } else {
                await MediaLibrary.addAssetsToAlbumAsync([asset], album, false);
                alert("File was downloaded to the Download folder ")
              }
            }).catch(err => console.log("Error: ", err));
          })
          .catch((err) => {
            console.log("Failed" , err);
            alert("Response failed something is up with the server")

enter image description here

0 Answers
Related