I am trying to upload pictures to amazon S3. I was successful using carrierwave. Then I switched to jQuery multi image upload. Following railscast 383.
my upload_helper looks exactly as shown; except the initialize method.
https://github.com/railscasts/383-uploading-to-amazon-s3/blob/master/gallery-jquery-fileupload/app/helpers/upload_helper.rb
following is in the page that user can upload their pics:
= s3_uploader_form post: items_url, as: "painting[image_url]" do
= file_field_tag :file, multiple: true
%script#template-upload{type: "text/x-tmpl"}
.upload
{%=o.name%}
.progress
.bar{ style: "width: 0%" }
I have the following js too:
//= require jquery-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require paintings
as it was shown in the tutorial
Even though my S3 upload was working fine with carrierwave and single file upload I am getting
failed to upload image error (coming from the last line in paintings.js.coffee). and
Failed to load resource: the server responded with a status of 400 (Bad Request)
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>XYZ</RequestId>
<HostId>
XYZ
</HostId>
</Error>
my CORS configuration is:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>http://localhost:3000</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Any guidance is very much appreciated
Found it!!!
In the upload_helper > S3Uploader > initialze add a timezone to your ‘expiration:’ like this:
That did the magic for me
Good luck