title: Check if file exists on Amazon S3
body: <p>So, what I'm trying to do is to check with Javascript if an image exists on my Amazon S3.</p>
  
  <p>I'm able to do this with the typical way of preloading the image and use <strong>onload</strong> and <strong>onerror</strong> events to check if the image is there.</p>
  
  <pre><code>var img = new Image;
  img.src = imageUrl;
  img.onerror = function()....
  img.onload = function()...
  </code></pre>
  
  <p>What I'm trying to achieve now is the same but without fully download the image.
  Let's say I have a possible 3mb image. If I check with the way I'm doing it now, if the image doesn't exist it'll go into the <strong>onerror</strong> event, I'll do a call to my server to generate the image and then I'll check again. When the image exists, it'll download the 3mb image and it'll go into the <strong>onload</strong> event.</p>
  
  <p>If the image doesn't exist, Amazon returns a <strong>403 Forbidden</strong> status code. If it does exist, it returns a <strong>200 Ok</strong> one.</p>
  
  <p>My question is: </p>
  
  <p><strong>Is there any way to just check the status code or any other way without fully download the image?</strong></p>
  
  <p>Thanks!!</p>