Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda