Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
How to get real Directory Path on iOS in React Native

I want to download a file in React Native and save it in a Directory selected by the User (e.g. Downloads).

Right now I'm using https://www.npmjs.com/package/react-native-document-picker to let the user pick a directory and https://www.npmjs.com/package/react-native-fs/v/1.2.0 to download the file.

Unfortunately, react-native-document-picker only gives me a dynamic URI to the directory, which does not exist when react-native-fs tries to access it. I think it's hidden behind something like a File-Provider.

I searched a lot but found no solution on how to get the real static path to a directory. Might be that I am missing something obvious, but I can not figure it out right now.

the code (simplified)

DocumentPicker.pickDirectory().then(pick => {

  // this looks something like:
  // file:///private/var/mobile/Containers/Shared/AppGroup/8443...EC/File%20Provider%20Storage/Downloads/
  const pickedDirectory = pick.uri;

  // resolves to false:
  RNFS.exists(pickedDirectory)

  // does not work
  RNFS.downloadFile({
    fromUrl: downloadUrl,
    toFile: pickedDirectory + filename,
  }).promise.then(r => { console.log(r)
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Either we can opt for the solution give on the below link (using react-native-fs).

React native Unable to use local tmp file path for Image.source iOS

or try

Add copyTo:"documentDirectory" in the pick document options. Then in pickedDirectory.fileCopyUri you'll get the document path.

What happens is when we pick any Item from gallery or iOS file system, it picks and place it a temporary directory for some time, then it get auto removed from that directory. Try the above given solution, I believe It will work.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!