-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
support load image from local document directory. #527
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Can you explain what the use case is? Are you saving images from the internet and you want to be able to read them? |
When react native out, I tried to create a camera app like Snapchat to test the native UI support. It goes pretty well until I need to load the saved image from app document to show user. The Image class supports local image from bundle but not from document folder where my capture image saved. Good framework! Waiting for Android feature. Thanks |
@phamhieu - would this work for you? https://github.com/facebook/react-native/blob/master/Libraries/Image/RCTImageLoader.m#L60-L72 |
@brentvatne Correct me if i'm wrong but I believe that block of code is used to support PhotoKit. My app just basic captures an image, adds text watermark and saves image in app document folder. I just want to load the image to show user as a preview before share/save to library... |
I'm unsure but isn't the CameraRoll class doing what you want? |
@vjeux But the image not saved in camera roll yet. my app flow:
So basic I need the ability to load image from app document on step 3 to show user so that he/she can edit it. With the current Image class, I cannot. Thanks |
return; | ||
} | ||
NSData *data = [NSData dataWithContentsOfURL:url]; | ||
callback(nil, [UIImage imageWithData:data]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UIImage *image = [RCTConvert UIImage:imageTag];
if (!image) { ... }
callback(nil, image);
Sounds like a valid use case to me... |
I knew I had seen that before, it's so valid that it already works! ;) <Image source={{uri: '/var/mobile/Containers/...'}} ... /> |
I did try that before. Just try it again but i receive error:
my code to load image:
|
@phamhieu - try adding |
@brentvatne can you give me an example. It'm not very sure how to add FYI: |
@phamhieu - |
@brendanv Yes, it works. Confirm that adding |
💥 fantastic, any chance you'll open source your app @phamhieu? I'd love to see it |
:) you can take a look here. https://github.com/phamhieu/ReactNativeExample I will need some more time to clean the code. But anything should be there. |
@phamhieu - thanks! I'll check that out tomorrow. I suppose we can close this issue now? |
Add support to load image from local document directory. Currently, it will show error when loading from document directory