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

Download file in downloads folder

Open uc-asa opened this issue 7 years ago • 22 comments

I need to downloaded file download in downloads folder of my device. When I downloaded file then it keeps in another place

uc-asa avatar Nov 05 '16 06:11 uc-asa

+1 facing same issue.

@uc-asa have you found a solution yet?

3210jr avatar Dec 12 '16 22:12 3210jr

Not yet if found any solution then inform me. I'm continuously working on it.

On Tue, Dec 13, 2016 at 4:22 AM, Junior Ally [email protected] wrote:

+1 facing same issue.

@uc-asa https://github.com/uc-asa have you found a solution yet?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/johanneslumpe/react-native-fs/issues/200#issuecomment-266579238, or mute the thread https://github.com/notifications/unsubscribe-auth/APpuJe98XIM6iWnNE41cfF6VRVCw9_xoks5rHdAigaJpZM4KqMLU .

-- Thanks,

Asheesh Kumar Sahu Software Engineer(Apps) uCertify

uc-asa avatar Dec 13 '16 02:12 uc-asa

Hi @johanneslumpe, by default i need to store downloaded file into downloads directory. But now it downloaded into /data/user/0/com.demoapp/files/ directory. I need your assistance to fix this issue.

ajeshrbt avatar Mar 04 '17 15:03 ajeshrbt

Any solutions?

gabriel-miranda avatar Jul 04 '17 19:07 gabriel-miranda

Please provide more info. What do you do? Whats your code? What happens exactly and what do you expect instead?

itinance avatar Jul 04 '17 19:07 itinance

react-native-fs gives you a few directories to download your file like DocumentDirectory. We need the Downloads directory from the device. Can you give us any advice?

gabriel-miranda avatar Jul 04 '17 23:07 gabriel-miranda

There is no specific download-directory of the device. You specify the final location by yourself and it will exactly download each byte onto this location and not some where else. If you don't believe me, just take a Debugger (XCode for iOS, Android Studio on Android) and step thru each line while downloading :) Does this answer your question?

itinance avatar Jul 05 '17 08:07 itinance

Not really. I needed a constant to find the external public storage to create my own folder. By the way Android has one. Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() Thanks for your time. I don't need any further help because I switched to another library.

gabriel-miranda avatar Jul 08 '17 04:07 gabriel-miranda

@gabriel-miranda, which one?

erbud avatar Jan 29 '19 18:01 erbud

Any progress on this? It would be great if react-native-fs provided additional directories similar to how react-native-fetch-blob (link) does it. After all I'd consider those a crutial part of file-system specifics.

ole-flavia avatar Oct 10 '19 14:10 ole-flavia

const path = ${RNFS.ExternalStorageDirectoryPath}/Download/${fileName}; Need to add the Download folder in the path. Files can then be found in Downloads.

adam-s avatar Dec 11 '19 19:12 adam-s

const path = ${RNFS.ExternalStorageDirectoryPath}/Download/${fileName}; Need to add the Download folder in the path. Files can then be found in Downloads.

Yes, but actually the Download part within that path should come from java android.os.Environment.DIRECTORY_DOWNLOADS. The problem is that we don't have access to that env variable in any way through react-native-fs. It's not ensured to always be just Download, although I didn't check whether it's actually something different under any circumstances. Even if it were always the same, using a static Download instead of android.os.Environment.DIRECTORY_DOWNLOADS is still dirty and error-prone.

ole-flavia avatar Dec 12 '19 09:12 ole-flavia

I have the same problem, but i fixed: example

 let options = {
                html: '<h1>PDF TEST</h1>',
                fileName: 'pdf1',
                directory: 'Download', // change Downloads for Download 
            };

            let file = await RNHTMLtoPDF.convert(options)
            // console.log(file.filePath);
            alert(file.filePath);
}

YuriLima23 avatar Jul 20 '20 22:07 YuriLima23

hlo friends ,i am working on react-native-viewShot and i want to store Screen Shot in my Mobile but i don't find any answer . View Shot in chache folder and i want to store View Shot in Downloads or Images folder please help me . Please Share your code of Storing ViewShot in Download folder. Thank You

Piyush132000 avatar Dec 05 '20 08:12 Piyush132000

Hi @johanneslumpe, by default i need to store downloaded file into downloads directory. But now it downloaded into /data/user/0/com.demoapp/files/ directory. I need your assistance to fix this issue.

hii bro are you find answer of your question because i have also same problem.

Piyush132000 avatar Dec 05 '20 08:12 Piyush132000

I agree the assertion that the constant should be more broadly available so we could use direct access to the right folders. rn-fetch-blob being unmaintened doesen't help too.

HugoGresse avatar Apr 19 '21 12:04 HugoGresse

const path = ${RNFS.ExternalStorageDirectoryPath}/Download/${fileName}; Need to add the Download folder in the path. Files can then be found in Downloads.

path should be const path = ${RNFS.ExternalStorageDirectoryPath}/Downloads/${fileName}

ahmedtahir123 avatar Nov 25 '21 07:11 ahmedtahir123

const path = RNFS.ExternalStorageDirectoryPath/Download/{fileName}; Need to add the Download folder in the path. Files can then be found in Downloads.

Surprisingly, this works. I was trying to create a folder in the top-level RNFS.ExternalStorageDirectoryPath but that fails. Appending the /Download fixes it and my folder now exists in the folder "Internal storage > Download" on the phone. Thanks.

Note: Without /Download it fails to create: /storage/emulated/0/banana (or at least I cannot view it on my phone) With /Download it creates the folder: /storage/emulated/0/Download/banana (and I can view this on my phone ok)

will-thrive avatar Feb 14 '23 14:02 will-thrive

const path = RNFS.ExternalStorageDirectoryPath/Download/{fileName}; Need to add the Download folder in the path. Files can then be found in Downloads.

Surprisingly, this works. I was trying to create a folder in the top-level RNFS.ExternalStorageDirectoryPath but that fails. Appending the /Download fixes it and my folder now exists in the folder "Internal storage > Download" on the phone. Thanks.

Note: Without /Download it fails to create: /storage/emulated/0/banana (or at least I cannot view it on my phone) With /Download it creates the folder: /storage/emulated/0/Download/banana (and I can view this on my phone ok) I am getting this error

ENOENT: no such file or directory, open '/storage/emulated/0/Downloads/mamasample-15s.mp3'

novamaster-git avatar Mar 14 '23 10:03 novamaster-git

I am getting this error

ENOENT: no such file or directory, open '/storage/emulated/0/Downloads/mamasample-15s.mp3'

It must be Download in singular. One reason why it should be a constant within this library...

ole-flavia avatar Mar 14 '23 10:03 ole-flavia

I am getting this error

ENOENT: no such file or directory, open '/storage/emulated/0/Downloads/mamasample-15s.mp3'

It must be Download in singular. One reason why it should be a constant within this library...

ya i used Download still getting this error

novamaster-git avatar Mar 14 '23 10:03 novamaster-git

@ole-flavia which android version you have tested it?

novamaster-git avatar Mar 14 '23 10:03 novamaster-git