Expose file path of cached images
My application support offline image display. it sync application content including images using a background service.
I need fresco to be able to check if downloaded images already existed in local, if not then download it from internet and save image to a cache. then cached image could later be referred by WebView img tag using file:\. Reason for doing all these are to save bandwidth by preventing app downloading image twice (Download image when view it in ListView through Fresco SimpleDraweeView), then download second time in WebView)
I am able to achieve this by using current Universal Image loader implementation: .diskCache(new UnlimitedDiscCache(FileManagerImage.getPath(),null, new Md5FileNameGeneratorEx()))
it point the cache folder and cache file name format to same folder where images are saved (same folder and same file name format) downloaded using backend service.
I have read Fresco Get Start, there is a way to change folder where cache files are saved, but the folder contain sub folder structures, plus I don't see anyway to format the file name.
Any idea how I could archive above requirement? Again simple requirements, 1. by given a URI, I need to pre-downloaded it, which can be later pick up by fresco as cache image. 2. by given a URI, i need to be able to locate image on the disk, and used it directly using file:///.
Duplicate of #80
Also, see ImagePipeline.prefetchToDiskCache
Thanks for the response and reference. ImagePipeline.prefetchToDiskCache solved my requirement 1. but how to solve 2. by given a URI, i need to be able to locate image on the disk, and used it directly using file:///.
I understand I can get the image object out, but I need to use the downloaded image in WebView which can only reference images as file:///. so are there anyway I could get the URI path to cached image file?
Duplicate of #80.
I don't understand why this enhancement is dupliate of #80 , plus, in #80, there are no resolution on how to get local physical cached file path by giving image url. please help.
again requirement is very simply, i am using ImagePipeline.prefetchToDiskCache to download image, and I want to share same cached image with WebView, which can only consume a image with <img to local physical path.
Please help. or someone point me to a solution to get a physical path of cached file by url
ImageRequest imageRequest=ImageRequest.fromUri(uriString); CacheKey cacheKey=DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(imageRequest); ImageRequest imageRequest=ImageRequest.fromUri(url); CacheKey cacheKey=DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(imageRequest); BinaryResource resource = ImagePipelineFactory.getInstance().getMainDiskStorageCache().getResource(cacheKey); File file=((FileBinaryResource)resource).getFile(); Log.i("TAG", file.getName());
Maybe you can use a TextView instead of WebView. And then customize the loading of images, in which you can use Fesco API without knowing the physical path of images. MoreI found TextView faster than WebView.