Upload to amazon S3

I am trying to upload photos to amazon S3. I was able to use the carrier wave. Then I switched to loading multiple jQuery images. After railscast 383.

my upload_helper looks exactly as shown; except for the initialization method. https://github.com/railscasts/383-uploading-to-amazon-s3/blob/master/gallery-jquery-fileupload/app/helpers/upload_helper.rb

Below is the page where the user can upload their photos:

    = 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 also have the following js:

//= require jquery-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require paintings

      

as shown in the tutorial

Even though my S3 boot was working fine with carrier support and one file, I get

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 config:

<?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 greatly appreciated

+3


source to share


1 answer


Found it !!!

In upload_helper> S3Uploader> initialze add the timezone to your "expiration" like this:

    expiration: 10.hours.from_now.utc,

      



It did magic for me

Good luck.

+4


source







All Articles