react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Can't use the downloadFile

Open guimiranda-dev opened this issue 8 years ago • 7 comments

Hello! I'm facing a difficult in use the lib. I'm trying to use the downloadFile and not return any errors and isn't working. This is my code:

RNFS.downloadFile({
  fromUrl: 'https://facebook.github.io/react-native/img/header_logo.png',
  toFile: `${RNFS.DocumentDirectoryPath}/react-native.png`,

}).promise.then((res) => {

  RNFS.exists('react-native.png').then((exists) => {

    console.log('exists');

  });
}).catch(() => {
  return Promise.reject(e);
});

Someone to help me please.

guimiranda-dev avatar Aug 03 '18 13:08 guimiranda-dev

I have the same issue, download file on android does nothing but works correct on IOS.

download = async (target, destination) => {
        try{
            let options = {
                fromUrl: target,
                toFile: destination,
                begin: (res) => {
                    console.log(res)
                },
                progress: (data) => {
                    console.log(data)
                },
                background: true,
                progressDivider: 1
            }
            console.log(options)
            const request = await RNFS.downloadFile(options).promise
            console.log(request)
        }catch(e){
            console.log(e)
        }
    }

I only get 1 console log which is options before the await, it does not time out or error.

elmbrent avatar Aug 06 '18 11:08 elmbrent

I upgraded to react-native-fs 2.10.14 and it fixed it

elmbrent avatar Aug 06 '18 12:08 elmbrent

Upgrading did not resolve this issue for me, happens only on Android devices.

beisert1 avatar Sep 14 '18 18:09 beisert1

I worked on version 2.9.12 in Android an IOS.

apipemc avatar Sep 17 '18 13:09 apipemc

I suspect this line. Following this issue I replaced the line with downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params); and it started working, but I don't know if it's correct approach here.

CptFabulouso avatar Jun 19 '19 10:06 CptFabulouso

I suspect this line. Following this issue I replaced the line with downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params); and it started working, but I don't know if it's correct approach here.

This is working too for me on Android 7 emulator and react native 0.57.8

AlexisReverte avatar Jun 25 '19 07:06 AlexisReverte

Funny, it was working for me without at first but then it stopped. This also fixed it for me.

DISKONEKTeD avatar Jul 07 '19 10:07 DISKONEKTeD