Rails direct upload to Amazon S3 using Activeadmin + Paperclip

I am using Activeadmin and Paperclip to make images upload on my Rails app. When I try to upload big files to S3 the timeout error occurs, so I have to implement the direct upload to S3.

Does anyone know how can I make it? I could't figure it out...


There is a really nice article I've used when was first time setting up the AA+s3+Paperclip .

It has decent explanations + example app on Github, so you can check it live.

In AA the form would look something like this:

form multipart: true do |f|
  # f.semantic_errors *f.object.errors.keys
  f.inputs do
    f.input :image_name #or whatever field is called
  end
    f.has_many :attachments do |a|
      if a.object.persisted?
        link_to image_tag(a.object.encoded_url, class: 'image-preview'), a.object.encoded_url, target: "_blank"
      else
        a.inputs do
          a.s3_file_field(:attachment, as: :file, class: 'js-s3_file_field')
        end +
        a.inputs do
          a.input(:s3_url, as: :hidden, input_html: { class: "s3_url" })
        end
      end  
    end
  f.actions
end

The answer appears to be in the comments. Thanks Andrey for the tutorial link.

http://blog.littleblimp.com/post/53942611764/direct-uploads-to-s3-with-rails-paperclip-and

链接地址: http://www.djcxy.com/p/81210.html

上一篇: 如何将UIToolbar添加到Storyboard上的NavigationController?

下一篇: Rails使用Activeadmin + Paperclip直接上传到Amazon S3