Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

compojoom
Copy link

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

return FastImage.loadImage({ uri: imageURL }).then(imagePath => ...)

and fast image won't try to redownload the image from the web.

@DylanVann please review and merge. Thanks!

Andrii Chernenko and others added 3 commits June 22, 2018 21:09
# Conflicts:
#	android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java
@asurare
Copy link

asurare commented Dec 18, 2018

@DylanVann You should accept this PR, this could be needed in a tons of projects

weichiwu referenced this pull request in weichiwu/react-native-fast-image Jan 28, 2019
@wbercx
Copy link

wbercx commented Jan 29, 2019

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.

@andriyslyusar
Copy link

Do we plan to merge this changes?

@luco
Copy link

luco commented Mar 22, 2019

@DylanVann Can you accept this PR?

@benwilburn
Copy link

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);

Copy link

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()
Copy link

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

)

Copy link

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);

Copy link

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

@rollsroyc3
Copy link

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..

@compojoom
Copy link
Author

@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.

@rollsroyc3
Copy link

@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

@enzzoperez
Copy link

Hello @compojoom, thank u for the PR. In my case, I'm getting an error

fastimage/FastImageViewModule.java:55: error: cannot find symbol
                    final GlideUrl glideUrl = FastImageViewConverter.getGlideUrl(source);
                                                                    ^

fastimage/FastImageViewModule.java:74: error: cannot find symbol
                final GlideUrl glideUrl = FastImageViewConverter.getGlideUrl(source);
                                                                ^

Have you an idea about what I'm doing wrong?

@DylanVann DylanVann changed the title Make it possible to obtain the cache path of an image Make it possible to obtain the cache path of an image. Oct 21, 2019
@DylanVann
Copy link
Owner

The API should be part of the preloading API, which is currently kind of blocked by SDWebImage.

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 DylanVann closed this Oct 21, 2019
@alexandrumic
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.