joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

RNFetchBlob is not working on Android 9.Plz help!!! #686

Open sai13mogli opened 3 years ago

sai13mogli commented 3 years ago

Hi ! Thank you for reporting an issue, but we would like to remind you, we have a trouble shooting page in our wiki. You may want to take a look on that page or find issues tagged "trouble shooting" :p

aftabaminzoobiapps commented 3 years ago

I have an issue. I am downloading a video file that is downloading to all other folders for example Downloads, Music, but through an error.

unsupported path /storage/emulated/0/VideoDownloader/TikTok/TIKTOKVIDEO .

` const normaldownload = dispatch => async (url, foldername , name_prefix) =>{

    let mydirs = RNFetchBlob.fs.dirs.SDCardDir
      var date = new Date()
      let checkdir = await RNFetchBlob.fs.isDir(`${mydirs}/VideoDownloader/${foldername}`);
        if(!checkdir){
          RNFetchBlob.fs.mkdir(`${mydirs}/VideoDownloader/${foldername}`).then((res) =>{
            console.log('created', res)
          }).catch((error) =>{
                console.log('Error', error)
          })
        }else{
            console.log("Dir existss")
        }

        try{  
          let options = {
            fileCache: true,
            addAndroidDownloads : {
              useDownloadManager :true, // setting it to true will use the device's native download manager and will be shown in the notification bar.
              notification : true,
              mime : 'video/mp4',
              description : 'Downloading Video',
              path:  mydirs+`/VideoDownloader/${foldername}/${name_prefix}`+Math.floor(date.getTime() + date.getSeconds() / 2) + '.mp4', // this is the path where your downloaded file will live in
            }
          }
          PermissionsAndroid.request(
            PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,{
              title: "Storage",
              message: "This app would like to store some files on your phone"
            }).then( async () => {  
                RNFetchBlob.config(options).fetch('GET', url).then((res) => {
                  console.log('path of the downloads ')
                  ToastAndroid.showWithGravityAndOffset(
                    `File Saved in VideoDownloader/${foldername}😃 `,
                    ToastAndroid.LONG,
                    ToastAndroid.BOTTOM,
                    25,
                    50
                  )
                }).catch((error) =>{
                  console.log(error,'ERRRROR')
                  ToastAndroid.showWithGravityAndOffset(
                    `Download Failed`,
                    ToastAndroid.LONG,
                    ToastAndroid.BOTTOM,
                    25,
                    50
                  );
              })
            })
    }
    catch(error){
      console.log("Error in catch " , error)
    }
  }

`

The above code WOrking fine on android 9 ad less but it through Error on android 10. I have already added this line. android:requestLegacyExternalStorage="true"

Still no improvement.

Only-IceSoul commented 3 years ago

Android 10 not accept old paths is depreceated. Use picture or movies folders from system.

Joshmatjjen commented 3 years ago

Just encounter this too.... is there a fix to it