Open franjorub opened 4 years ago
https://github.com/joltup/rn-fetch-blob/wiki/File-System-Access-API#dirs
Only DocumentDir
, CacheDir
, and MainBundleDir
are available in iOS.
I just tried RNFetchBlob.fs.mkdir(RNFetchBlob.fs.dirs.DocumentDir + '/' + uuid);
with 0.10.5 and RN 0.59.9; works fine in the simulator without needing any additional permissions.
@Transfusion Thanks but don't know where to find the files have tried opening the Files app but can't find anything there, although I'm working from an emulator not sure if that is an emulator limitation?
This is for a case where I'm downloading straight to a directory.
@thecodecafe Same thing here, the file gets into the file system, but cannot access it through the file app, I am also beginning to think it is an emulator limitation, I'll try to get my hands on a physical device and let you know.
@PaperbagWriter Tried it on a physical device and the files aren't showing up, plus I don't even think they get stored because after downloading to Documents I persist the download path for later but every time I run a check to see if the file exists, it doesn't, still looking into it to know what might be the cause though.
@thecodecafe @PaperbagWriter Hi! Just walked by. But recently I worked with a similar story. You need permissions in info.plist
that will be available for the system and other files. Here's what you need:
<key> LSSupportsOpeningDocumentsInPlace </key>
<Truth />
<key> UISupportsDocumentBrowser </key>
<Truth />
<key> UIFileSharingEnabled </key>
<Truth />
(the fact that in the middle is not necessary, but I decided it would be better).
O wow thanks @JerakRus will try this in the morning at it's 11 pm here right now, thanks a bunch.
Thanks @JerakRus it worked, I can now see the saved files in the File app on iOS.
@thecodecafe Glad I could help!
could be included @JerakRus answer in the docs ? I don't know if this is a common use case
@thecodecafe @JerakRus Thanks that is great I actually thought it was not possible!
I also found that you can instead use
ios.previewDocument
After the file is downloaded into the cache without adding permissions, that way the user can decide where he wants to save it. It seems to feel more like the expected behavior on iOS.
For android you need to scan the files once they are downloaded in your directory of choice. Hope that helps.
@thecodecafe @JerakRus Obrigado, isso é ótimo, na verdade pensei que não era possível!
Também descobri que você pode usar
ios.previewDocument
Após o download do arquivo para o cache sem adicionar permissões, o usuário pode decidir onde deseja salvá-lo. Parece mais com o comportamento esperado no iOS.
Para o Android, você precisa verificar os arquivos depois de baixá-los no diretório de sua escolha. Espero que ajude.
Sorry, I don't have an IOS emulator to test, but I would like to know what the correct solution is?
In your case just using ios.previewDocument
can the user save the file where he wants?
In my case I want to save the file to a location on Android and IOS is the user's choice.
@marquinmpfs
Hello! The permissions described above are used so that you can select a file from the device, and not for saving. They are not needed for your situation. But maybe others are needed, here I honestly won't tell you, I don't remember anymore =)
@marquinmpfs Hello! The permissions described above are used so that you can select a file from the device, and not for saving. They are not needed for your situation. But maybe others are needed, here I honestly won't tell you, I don't remember anymore =)
Okay, thanks anyway.
I try with documents and download dirs but they return undefined, how should be the path for iOS ?