Skip to content

Instantly share code, notes, and snippets.

@chrisseto
Created February 5, 2014 16:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisseto/8828186 to your computer and use it in GitHub Desktop.
Save chrisseto/8828186 to your computer and use it in GitHub Desktop.
uploadMethod: 'PUT',
uploadAdded: function(file, item) {
//Recieve the signed PUT request here
//I can create another GIST if anyone would like the code for signing the requests
mydropzone.options.url = url;
},
uploadSending: function(file, formData, xhr) {
xhr.setRequestHeader('Content-Type', file.type || 'application/octet-stream');
xhr.setRequestHeader('x-amz-acl', 'private');
}
/*
Cors config for your bucket:
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
The * can be changed out, I just didnt feel like recording all the additional headers
If allowed origin is managed properly having a wild card for headers should not be an issue
*/
@teechap
Copy link

teechap commented Feb 13, 2014

Thanks a million for uploading this! If you could post the code for signing requests I'd like that too. =P

@chrisseto
Copy link
Author

See here for how to do it in python.
Otherwise there are plenty tutorials on google!

@teechap
Copy link

teechap commented Feb 20, 2014

Thanks again, this helped a lot

@OleMchls
Copy link

OleMchls commented Aug 9, 2014

thanks! 👍 if anyone is curious how to get a signed url in ruby check the official gem http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/S3Object.html#url_for-instance_method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment