private LocalImageFetchResult StoreLocalImage(ImageFetchResult image) { var newFileName = GetNewFileName(image.ImageLocation); File.Copy(image.ImageLocation, newFileName); return(new LocalImageFetchResult(newFileName, image.Reference)); }
private LocalImageFetchResult StoreRemoteImage(ImageFetchResult image) { using (var webClient = new WebClient()) { var imageData = webClient.DownloadData(image.ImageLocation); //var newFileName = GetNewFileName(StripQueryString(image.ImageLocation)); var newFileName = GetNewFileName(image); SaveImage(newFileName, imageData); return(new LocalImageFetchResult(newFileName, image.Reference)); } }
private string GetNewFileName(ImageFetchResult image) { return(Path.Combine(ConfigurationManager.AppSettings["TemporaryImageStorePath"], $"{image.Source}_{Guid.NewGuid()}.{StripQueryString(image.ImageLocation).Split('.').Last()}")); }
private LocalImageFetchResult StoreImage(ImageFetchResult image) => image is LocalImageFetchResult?StoreLocalImage(image) : StoreRemoteImage(image);