-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Make it possible to obtain the cache path of an image. #351
Conversation
# Conflicts: # android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java
@DylanVann You should accept this PR, this could be needed in a tons of projects |
This would be really useful. I'm currently looking to add functionality for drawing on images in my app, which requires a local path to a file. FastImage will already have downloaded and cached the image to display a thumbnail, prior to the canvas opening up. It would be nice to just re-use that particular image file, rather than downloading another copy to disk, and dealing with it manually. |
Do we plan to merge this changes? |
@DylanVann Can you accept this PR? |
Any update on this feature? @DylanVann |
@@ -33,6 +43,7 @@ public void preload(final ReadableArray sources) { | |||
public void run() { | |||
for (int i = 0; i < sources.size(); i++) { | |||
final ReadableMap source = sources.getMap(i); | |||
|
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.
You should keep the author's code style, by removing this empty line between variable declarations ;)
@@ -45,12 +56,47 @@ public void run() { | |||
// - data:image/png;base64 | |||
.load( | |||
imageSource.isBase64Resource() ? imageSource.getSource() : | |||
imageSource.isResource() ? imageSource.getUri() : imageSource.getGlideUrl() | |||
imageSource.isResource() ? imageSource.getUri() : imageSource.getGlideUrl() |
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.
Same thing, keep the indentation here please :3
) | ||
|
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.
Aaaand this empty line ;)
@Override | ||
public void run() { | ||
final FastImageSource imageSource = FastImageViewConverter.getImageSource(activity, source); | ||
|
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.
And finally removing this empty line
Thanks for adding this functionality, very helpful. One thing I noticed is the files that are stored locally have an odd filename/extension. For example in iOS, the file extension takes the extension of the url you downloaded it from. So if im hitting www.somedomain.com/getImage.aspx?id=5 the file extension will be .aspx. On Android it just seems like the file extensions are all .0 Has anyone ran into issues with sharing to other applications where this file extension issue would cause a problem? Even Gmail, the images do not show a preview since the file extension is wrong. Im hoping to avoid copying all the images locally and renaming the extension since were so close, but not sure of a way around it.. |
@rollsroyc3 - hm, I haven't looked into this. I'm always grabbing the local image and converting it to base64, then I pass it to whatever shринг service on the phone and that works. |
Im curious why you would convert to base64, passing the uri works just fine, and I imagine is less memory intensive. I'll go ahead and give that a try though and see what it looks like in gmail, etc.. thanks |
Hello @compojoom, thank u for the PR. In my case, I'm getting an error
Have you an idea about what I'm doing wrong? |
The API should be part of the preloading API, which is currently kind of blocked by Sorry, if you find a way to resolve the issues around it feel free to open another PR. As is I don't want to add another API specifically to do this. Notes are here: https://github.com/DylanVann/react-native-fast-image/blob/master/docs/roadmap.md#add-onprogress-and-oncomplete-to-preload |
@DylanVann Do you think this will be added soon? I think it will help a lot of people and will be a very helpful feature 🤞. I'm currently working on integrating FastImage with a native module Image Gallery which is using images URI and in offline mode can't display the images because I have to sent it the local paths of them. Great library! |
I'm just merging the master with the changes @andriichernenko made.
His original pull request is here:
#228
I had to resolve the conflicts in the FastImageViewModule - please review it as I'm not that good with java.
If you try to do yarn add from my branch https://github.com/compojoom/react-native-fast-image/tree/cache-path installation will fail because of the package.json prepare command. I've temporally disabled it here:
So you can use this branch https://github.com/compojoom/react-native-fast-image/tree/develop to check the changes.
With this pull request applied you should be able to do
and fast image won't try to redownload the image from the web.
@DylanVann please review and merge. Thanks!