title: Spring Application - Getting images on Amazon S3 to client
body: <p>I am building a Spring Web Application hosted on Elastic Beanstalk. I use S3 to store user uploaded images which works great. What I don't understand is how fetching images from S3 to the client work. I found three alternatives.</p>
  
  <p>1.Get the image in a controller and send it to the client. Like this:</p>
  
  <pre><code>S3Object object = amazonS3Client.getObject("bucketname", "path/to/image");
  </code></pre>
  
  <p>2.Open up all images and reach it directly by an URL in the client. Something like this:</p>
  
  <pre><code> &lt;img src="http://aws.amazon.com/bucket/path/to/image.jpg"&gt;
  </code></pre>
  
  <p>3.Use signed download URLs that only working for a certain time. Like this:</p>
  
  <pre><code>GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest("bucketname", "path/to/image");
  String url = conn.generatePresignedUrl(request)
  </code></pre>
  
  <p>Im not sure which approach to go for. Routing it through the web server seems unnecessary, since it loads the server. Open the URLs to anyone might higher requests and costs since anyone can use the images. And the third way is new to me, haven't really seen anyone practising this which makes me insecure if this is really the way to go. </p>
  
  <p>So, how is this usually done?</p>
  
  <p>And how is this used in the development environment versus production environment. I guess its not changing? Or is it common to use spring profiles to change the location of static content while developing and only use S3 for production?</p>
  
  <p>If your hosting Javascript, CSS on S3, is it then most common to go for approach 2 and open them up for everyone?</p>