title: Show a thumbnail image in gallery but download the original
body: <p>I have a gallery of images that are loaded dynamically from the database. The original images weigh approximately 3Mb each, so I am making a Thumbnail of each one so I can optimize my web page. Thanks to the thumbnail, the images now weigh approximately between 300kb and 500kb.</p>
  <p>The images when I get them from the database, I save them in a list and this is passed through the thumbnail function, and then sent to the view.</p>
  <p>My problem is the following: I want each image to be downloadable either all together or one by one. I have been able to complete this task successfully, but the images that are downloaded are the thumbnails, when the ones I want to download are the originals.</p>
  <p>How could I load the thumbnail images in the gallery and download the original ones?</p>
  <p>I have tried to save the copies in a folder both in <code>TMP/Temp</code>, create a new directory such as wwwroot/TemporalImages, or save them in memory. The problem with the folders is that I don't have write permissions. And with saving the images in memory I did not find something that worked, since most of them I saw use <code>Bitmap</code> or <code>Encoder</code> but I get a warning that they are only functional for Windows, and my project is hosted on a Linux server.</p>
  <p>I need your help, I've had this problem for a few days and I can't find a way around it.</p>
  <pre><code>// I recover the images with the Query, then pass the list to &quot;Chang Image Size&quot;
  private List&lt;OrderViewModel&gt; ViewOrder(string identi)
          {
              List&lt;OrderViewModel&gt; OrderList;
              string query;
  
              try
              {
                  OrderList = new List&lt;OrderViewModel&gt;();
                  query = &quot;query&quot;;
  
                  OrderList = SelectMySqlConnection(query);
  
                  ChangeImageSize(orderList);
  
                  return OrderList;
              }
              catch (Exception ex)
              {
                  throw new Exception(ex.ToString());
              }
      }
   
   // I create the temporary folder (tempFolder), do a foreach loop for the List and save each image
   private void ChangeImageSize(List&lt;OrderViewModel&gt; orderViewModels)
          {
              const int thumbnailWidth = 500;
              string tempFolder;
  
              try
              {
                  tempFolder = TemporaryFolder();
  
                  foreach (var item in orderViewModels)
                  {
                      var imageResult = Image.Load(&quot;wwwroot/&quot; + item.getImages());
  
                      this.SaveImage(imageResult, tempFolder, thumbnailWidth);
                  }
              }
              catch (Exception ex)
              {
                  ViewBag.error = ex.Message.ToString();
                  throw new Exception(ex.Message);
              }
          }
  //Resize the image and then save it
  private void SaveImage(Image image, string name, int resizeWidth)
          {
              var width = image.Width;
              var height = image.Height;
  
              if (width &gt; resizeWidth)
              {
                  height = (int)((double)resizeWidth / width * height);
                  width = resizeWidth;
              }
  
              image
                  .Mutate(i =&gt; i.Resize(new Size(width, height)));
  
              image.Metadata.ExifProfile = null;
  
              image.SaveAsJpeg(name, new JpegEncoder
              {
                  Quality = 100
              });
          }
  //Create or recover temporalFolder
          private string TemporalFolder()
          {
              DirectoryInfo result = Directory.CreateDirectory(@&quot;wwwroot/imgAndroid/TemporalImages/&quot;);
  
              return result.FullName;
          }
  </code></pre>
  <p>In addition to all that, when I try it locally or in production, I have this error:</p>
  <blockquote>
  <p>System.Exception: Access to the path 'C:\Users\Users\source\repos\DevelopmentWebLogistica\WebLogistica\wwwroot\TemporalImages' is denied. at WebLogistica.Controllers.HomeController.ChangeImageSize(List`1 orderViewModels) in C:\Users\Users\source\repos\DevelopmentWebLogistica\WebLogistica\Controllers\HomeController.cs:line 289 at WebLogistica.Controllers.HomeController.VerOrder(String identi) in C:\Users\Users\source\repos\DevelopmentWebLogistics\WebLogistics\Controllers\HomeController.cs:line 157</p>
  </blockquote>
  <p>Line 157 is <code>ChangeImageSize(orderList);</code></p>