public Task <byte[]> GetImageAsync(int id, TvMazeImageCollection image, string folderPath) { string imageUrl = image.OriginalUrl ?? image.MediumUrl; string cacheFileName = CreateAndGetCacheName(id, imageUrl, folderPath); if (string.IsNullOrEmpty(cacheFileName)) { return(Task.FromResult <byte[]>(null)); } return(_downloader.ReadDownloadedFileAsync(cacheFileName)); }
/// <summary> /// Downloads images in "original" size and saves them to cache. /// </summary> /// <param name="image">Image to download</param> /// <param name="folderPath">The folder to store the image</param> /// <returns><c>true</c> if successful</returns> public async Task <bool> DownloadImageAsync(int id, TvMazeImageCollection image, string folderPath) { string imageUrl = image.OriginalUrl ?? image.MediumUrl; string cacheFileName = CreateAndGetCacheName(id, imageUrl, folderPath); if (string.IsNullOrEmpty(cacheFileName)) { return(false); } string sourceUri = imageUrl; return(await _downloader.DownloadFileAsync(sourceUri, cacheFileName).ConfigureAwait(false)); }
/// <summary> /// Downloads images in "original" size and saves them to cache. /// </summary> /// <param name="image">Image to download</param> /// <param name="folderPath">The folder to store the image</param> /// <returns><c>true</c> if successful</returns> public bool DownloadImage(int id, TvMazeImageCollection image, string folderPath) { string imageUrl = image.OriginalUrl ?? image.MediumUrl; string cacheFileName = CreateAndGetCacheName(id, imageUrl, folderPath); if (string.IsNullOrEmpty(cacheFileName)) { return(false); } string sourceUri = imageUrl; _downloader.DownloadFile(sourceUri, cacheFileName); return(true); }