Expo reactnative FileSystem is not saving my file on my device

162 Views Asked by At

I used different method to do this and all didnt work but when I tried downloadasync it showed little light but didnt work.

const downloadFile = async (url) => {
    try {

      console.log("Started");
      setLoadingModal(true)
      // const response = await fetch(url);
  
      console.log(url);
      // Get the file name from the URL or the Content-Disposition header
      const fileName = url?.split('/')[url?.split('/').length-1]
      
      //path to download
      const path=FileSystem.documentDirectory+"FirstOG/"

      FileSystem.getInfoAsync(path).then(({exists}) => {
        if (!exists) {
          console.log(exists);
          FileSystem.makeDirectoryAsync(path)
        } else {
          null
        }
      })

      let file= await FileSystem.downloadAsync(
        url,
        path+ fileName,      
      )

      console.log(file);
    
      Linking.openURL(file.uri)
      console.log("go");
  
  
      console.log(`File saved to ${file.uri}`);
    } catch (error) {
      console.error('Error downloading file:', error);
    }finally{
      setLoadingModal(false)
    }
  
 
};

It didnt save the file to my mobile device and i hav checked the route well and still nothing

If I use CreateDownloadResumable it gave this error below [TypeError: 0, _expoModulesCore.uuidv4 is not a function (it is undefined)]

I tried permissions but nothing changed I even built it and nothing

i was expecting my file to be saved unto the phone. I tried using permission and other things.

0

There are 0 best solutions below