-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] Don't assume that the absolute uri returned will persist #107
Comments
I'm not sure I follow... The Documents folder should always persist for an app on the same device. Are you using the iOS simulator? |
yep I'm using iOS simulator, but i have tested it into app in production. |
Gotcha, so the path TO the Documents directory could change, but once inside your Documents directory, everything remains the same. I think this falls a little outside the responsibility of this image picker component. We are returning the absolute path where the photo is at that current moment, AND since the photos are being saved to the Documents directory, we've guaranteed that they will be persisted forever on the device as long as the app is installed. It should be up to the developer to then know to never rely on the absolute path and maybe use something like react-native-fs to find the path to the Documents directory. This is definitely valuable information to know though, so thank you! |
@marcshilling you are right ... it is outside the the responsibility of this image picker component. But the picker return an absolute path and it's good to inform the coder about the possibility to loose their (only the reference) photo. |
I added a note to the README referencing this issue. Thanks for bringing it my attention! |
Hello, Wouldn't it be good then if the plugin also returned only the filename? |
Just letting you know that I found an alternative to using react-native-fs. A path prepended with |
The tilde did not work for me, so I save images as base64 if iOS, and as a URI if Android. |
@i-tu This solution works if you prefix with ~/Documents/images e.g. |
I wanna send the uri of image to the API. all things is ok on android and when choose photo from gallery on IOS but when I take photo on IOS is something wrong. here is my code. if my problem related to this issue please give me some hint how could I get the correct uri for passing to API?
|
@Max93 could you give me some hint how could I get the uri when I'm taking the photo on IOS? |
@i-tu could you please give me more description?
|
@jsina, I get the same issue, you sovle it now? |
@xhw1993 this is all what I've done
|
@jsina use this for ios |
I run into this issue as well, but my source was RNCamera. in some phone the "~" fix the problem to recover images but there was phone where only react-native-fs worked to get the correct path (which works for ios and android):
source: https://stackoverflow.com/questions/39286211/react-native-ios-read-image-from-apps-documents-folder |
Yes that works for me...Thanks for sharing. |
Updated the title to make it easier to understand the problem while pinned. |
This is not working for me. After closing metro server and restarting the app i cant open the file |
On iOS images was stored in Documents folder. The Document folder was stored into an folder with an hexadecimal name. This folder is regenerated and renamed for each build. For this reason if you store the absolute URL of image you loose the reference from it.
For this reason I propose to return the name of the image and the path declared on storageOptions.
I know is simple to get this information from absolute URL (simple JS String manipulation) but for me is important to inform programmer of the possibility to lose their references from love pictures.
Thank's.
The text was updated successfully, but these errors were encountered: