title: How to properly upload an object to AWS S3?
body: <p>After three days of chasing this problem. It's time to ask for some help.
  I have a signed url to upload a file to Amazon S3.  I know this is correct, since a</p>
  
  <pre><code>curl -v -T file.png --header "Content-Type:binary/octet-stream" "https://sample.s3.amazonaws.com/33d7e8f0-0fc5-11e5-9d95-2b3410860edd?AWSAccessKeyId=XXXXXXXX&amp;Content-Type=binary%2Foctet-stream&amp;Expires=1433984735&amp;Signature=LUjj8iIAbCfNoskGhqLDhuEWVG4%3D"
  </code></pre>
  
  <p>succeeds correctely.  </p>
  
  <p>But my .ajax code (below) which does the upload leaves the content garbled slightly in the S3 bucket.<br>
  For example if I upload a .pdf file, it loads properly from the S3 Management Console, but if it is a .png or .jpeg, etc. it fails... And looking closely the file has the wrong length (slightly).</p>
  
  <p>The heart of the call in the browser is:</p>
  
  <pre><code>var formData = new FormData();
  formData.append("upload", file);
  $.ajax({ url: data.puturl,
           type: 'PUT',
           xhr: function() {
             var myXhr = $.ajaxSettings.xhr();
             if (myXhr.upload) {
               myXhr.upload.addEventListener('progress', progressHandlingFunction, 
                                             false);
             }
             return myXhr;
           },
           success: completeHandler,
           error: errorHandler,
           data: formData,
           cache: $.param(false),
           contentType: "binary/octet-stream",
           processData: $.param(false)
           }, 'json');
  </code></pre>
  
  <p>This almost seems to work, but the data is garbled.  I have tried  setting the content to file.type, etc. to no avail.  Is there some encoding that I need to do here? Such as base64 that I am missing????</p>
  
  <p>Any insight would be greatly appreciated.<br>
  OR if there is an easy way to not use .ajax to do the same thing, that would be great.</p>