fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Through a network url, get local cache file path

Open xiang-jian opened this issue 11 years ago • 5 comments

xiang-jian avatar Oct 09 '15 08:10 xiang-jian

if you mean by the file path for downloaded images in Bitmap cache/Disk cache, they don't have file path as they're not real file

aagnes-zz avatar Oct 09 '15 09:10 aagnes-zz

There is no way to get to the local cache file path?

YuhuihuiYang avatar Oct 10 '15 08:10 YuhuihuiYang

May I ask why do you need to get the local cache file path?

aagnes-zz avatar Oct 11 '15 19:10 aagnes-zz

@aagnes I need to be stored or forwarded pictures

xiang-jian avatar Oct 12 '15 00:10 xiang-jian

    File getDiskCacheFile(String url) {
        ImageRequest imageRequest = ImageRequest.fromUri(url);
        CacheKey cacheKey = DefaultCacheKeyFactory.getInstance()
                .getEncodedCacheKey(imageRequest);
        BinaryResource resource = Fresco.getImagePipelineFactory()
                .getMainDiskStorageCache()
                .getResource(cacheKey);
        if (resource instanceof FileBinaryResource) {
            return ((FileBinaryResource) resource).getFile();
        }
        return null;
    }

yrom avatar Oct 14 '15 15:10 yrom