title: Webcam js upload image to Amazon S3
body: <p>I'm trying to upload an image taken with </p>
  
  <p><a href="https://github.com/jhuckaby/webcamjs" rel="nofollow">Webcam js</a></p>
  
  <p>directly to Amazon S3</p>
  
  <pre><code>var dataUri = Webcam.snap();
  var raw = window.atob(dataUri.replace(/^data\:image\/\w+\;base64\,/, ''));
  </code></pre>
  
  <p>and after I get the policy (which is correct) I do this </p>
  
  <pre><code>$.ajax({
          type: 'POST',
          url: amazonUploadUrl,                                
          data: {
                file: raw,
                contentType: "image/jpeg",
                key: key,
                AWSAccessKeyId: awsAccessKey,
                acl: "public-read",
                policy: policy,
                signature: signature,
                name: "",
                Filename: filename
                },
                dataType: "",
                success: function (r1) {
  
                }
          });
  </code></pre>
  
  <p>I've tried sending the encoded image, the decoded image, I've tried modifying the headers. All I keep getting is this </p>
  
  <p><em>XMLHttpRequest cannot load 'amazon s3 bucket url'. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'my local domain' is therefore not allowed access.</em> </p>
  
  <p>I've added the CORS info on the Amazon bucket.
  I'm already uploading images to that bucket using plupload. 
  I've also uploaded images from a standard  without using ajax.
  I just can't seem to get this to work.</p>
  
  <p>Any ideas?
  Thanks</p>
  
  <p>PS: I've also tried using </p>
  
  <p><a href="http://www.xarg.org/project/jquery-webcam-plugin/" rel="nofollow">jquery webcam plugin</a></p>
  
  <p>With the same result</p>