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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With