-
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 #228
Conversation
@DylanVann any comments or thoughts? |
@andriichernenko Could you please give a reason why this should be added to the API? Also this is a Android only implementation. Have you planned to also add the ios counterpart? |
@andriichernenko I overlooked that file sorry |
@andriichernenko - can you give an example on how to use this? |
Here's an example usage:
If this PR is accepted, I will update the docs. The idea is that if the image has been downloaded before (for example, if it has been displayed somewhere), the path to its copy in the cache will be returned. Otherwise, it will be downloaded first. There might be a catch though. As I understand, Glide uses things like target image size to generate the cache key. These things are not possible to determine if the target view is not known, so this might mean it will be downloaded again (because it was not found in the cache). I am not really familiar enough with Glide to say whether this is the case or not. |
This sounds exciting! I'll try to test this. What do you mean with a "target image size". The way I understand it the image is downloaded based on the url? So, if it is downloaded once, it won't be downloaded again. |
I read somewhere in the Glide's GitHub issues (can't seem to find the relevant issue now) that they may store multiple resized copies of an image in the cache. But, of course, this should not affect downloads, so never mind. |
@andriichernenko amazing! Just added this to iOS and the difference between - manually fetching the image and using this to get the path to it is enourmous! Previously it took like 10s to fetch the image, convert it to base64 and display the share screen. Now it is nearly instant... A question though - how are we supposed to test this pull request? I tried doing:
but this was failing with
So I manually added the changes to the files... But I would like to use this pull request till it gets merged. @DylanVann could you merge this? |
@compojoom I ran into this issue as well, it is caused by yarnpkg/yarn#1488. I "fixed" it by removing the script that fetches git submodules (see softwerkab@2d7b399). Since all dependencies in git submodules are added via Cocoapods anyway, everything seems to work. |
Thanks! Tested now on android as well. It works. One thing to note on android is that the returned URI doesn't have a file: prefix and if you try to process this further one gets an error. |
The intention is to return the path, so that's what the method does on both Android and iOS. Is there a reason we need a URI?
Can you elaborate? |
doesn't matter. I added a file:// to it and it seems to work both on ios and android. this is how I use it together with react-native-share
|
Hey, can we proceed with merging this pull request? |
I think put the
|
@compojoom |
@retyui - I'm not the maintainer of the project and don't have commit access. @DylanVann would have to merge this. |
@DylanVann kindly merge this as soon as possible. |
I really need this feature as well. A few use cases:
@andreyslyusar can you rebase this ? |
hey guys! I've made a new pull request #351 that resolves the current conflicts this branch has. Please review it and let's get this merged. |
Sorry, I was busy with another project. @compojoom thanks for taking care of resolving conflicts. @DylanVann can you help us merge #351 and close this pull request as duplicate? |
This pull request adds the
FastImage.loadImage(source)
method which fetches the image and returns the path to its copy in the disk cache.This may not be useful for everybody, but I figured I'd open a PR anyway.