CachedImage - Access the downloaded file

Barto 26 Reputation points
2021-03-30T12:39:05.397+00:00

I am using the CachedImage component of ffimageloading. I have a kind of gallery with a carousel view.

All the images are loaded through an internet URL, they are not local images. I would like to add the image sharing function. But I don't want to download the file again, I would like to know if there is a way to access the file that the CachedImage component already downloaded to be able to reuse it in the share function.

Developer technologies .NET Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,971 Reputation points
    2021-03-30T13:30:57.49+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Hi, Barto. To get the cached image, try using the MD5Helper.

       var filepath = ImageService.Instance.MD5Helper.MD5("the file url");  
    

    Refer to: https://github.com/luberda-molinet/FFImageLoading/issues/1214#issuecomment-472073935

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Barto 26 Reputation points
    2021-03-30T15:27:14.22+00:00

    Thanks @JarvanZhang

    I share with you how part of my code is:

       var key = ImageService.Instance.Config.MD5Helper.MD5("https://yourfileUrlOrKey");  
       var imagePath = await ImageService.Instance.Config.DiskCache.GetFilePathAsync(key);  
       var tempFile = Path.Combine(Path.GetTempPath(), "test.jpg");  
       if (File.Exists(tempFile))  
       {  
           File.Delete(tempFile);  
       }  
       File.Copy(imagePath, tempFile);  
      
       await Share.RequestAsync(new ShareFileRequest  
       {  
           Title = "Test",  
           File = new ShareFile(tempFile)  
       });  
    

    The temporary file I believe, since the cached file has no extension and the applications do not recognize the type.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.