-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat(android): add support for opening file:// URIs for reading #16
Conversation
If adding support this way, read calls on android will support We should also support uri scheme on iOS. |
Yes, I didn't change those calls in the example app, and I didn't saw an error there. We could add this to rename as well?
Which one do you have in mind? I'm currently working on support for ph:// URIs, which is also "just" a react-native thing (3rd party libs and RN are using them to resolve to the internal photo library). |
Hmm. Looks like it works by parse yields an empty scheme when none is provided. Valid URIs require scheme, so I think this works by relying on implementation behavior instead of specs https://developer.android.com/reference/android/net/Uri#parse(java.lang.String) . Perhaps safer to confirm path looks URI-ish before using it as such?
Perhaps add a helper function that returns a
At least Thanks for your work on this. |
Yep, I can add the support for making the distinction between URIs and file paths.
Sure, I can look into that. Regardless of that - do you have any plans to integrate some testing into the lib? |
Tests would be great, but I have not written tests targeting native code in react native before and am not certain how to approach. Writing jest tests for the js side does not currently feel useful, since basically the only js logic is adding default parameters to native calls. Any suggestions? |
Not really, the first thing which comes to my mind would be Firebase test-lab for E2E testing. But that requires a lot of preliminary setup. We could start with simply unit testing both native code bases in the first places. Other than that, updated the series. |
Most popular RN 3rd party libraries handling files (e.g. image/photo handling) are returning file:// URIs on Android. To save handling this in JS several times, we can simply try to detect if we are handling an URI and parse them accordingly. Regardless of the input we always return an File object to handle files. Signed-off-by: Martin Mazein <internet+github@mazein.net>
Most popular RN 3rd party libraries handling files (e.g. image/photo handling)
are returning file:// URIs on Android. To save handling this in JS several
times, we can simply parse the input string as an URI and use the path part to
open files.
Signed-off-by: Martin Mazein internet+github@mazein.net
Testing done
Added an additional test in the Example App. Also tested the patch within my apps, which handle file URIs from e.g. react-native-image-cropper-picker.