예제 #1
0
        private LocalImageFetchResult StoreLocalImage(ImageFetchResult image)
        {
            var newFileName = GetNewFileName(image.ImageLocation);

            File.Copy(image.ImageLocation, newFileName);
            return(new LocalImageFetchResult(newFileName, image.Reference));
        }
예제 #2
0
 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));
     }
 }
예제 #3
0
 private string GetNewFileName(ImageFetchResult image)
 {
     return(Path.Combine(ConfigurationManager.AppSettings["TemporaryImageStorePath"],
                         $"{image.Source}_{Guid.NewGuid()}.{StripQueryString(image.ImageLocation).Split('.').Last()}"));
 }
예제 #4
0
 private LocalImageFetchResult StoreImage(ImageFetchResult image) => image is LocalImageFetchResult?StoreLocalImage(image) : StoreRemoteImage(image);