Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails direct upload to Amazon S3

I'm looking to add functionality to my Rails app to upload files directly to Amazon S3. From my research the general consensus seems to be to use the s3-swf-upload-plugin. I've setup a sample app using that gem but I can't get it to play nice with only allowing the selection of a single file. I'd also like to create a record post upload and use paperclip to create a thumbnail for which I can find little guidance.

So my questions are:

(1) am I on the right track using that gem or should I be taking another appraoch?

(2) are there any samples out there that I could use for reference?

Any assistance would be much appreciated.

Chris

like image 942
Chris Hilton Avatar asked May 25 '11 15:05

Chris Hilton


People also ask

How do you upload pictures to S3 bucket in Ruby on Rails?

1- Navigate to services menu -> click S3 -> click create bucket. 2- Enter a bucket name, and choose a closest region to you. for the bucket name I usually use app-name and end it with dev or pro as you see in the next picture. you will click 3 times next, and finally click the create bucket button.

What is Activestorage?

Active Storage facilitates uploading files to a cloud storage service like Amazon S3, Google Cloud Storage, or Microsoft Azure Storage and attaching those files to Active Record objects.

What is AWS S3 client?

Amazon S3 provides storage for the Internet, and is designed to make web-scale computing easier for developers. The Amazon S3 Java Client provides a simple interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web.


2 Answers

Try a new Gem called CarrierWaveDirect it allows you to upload files direct to S3 using a html form and easily move the image processing into a background process

like image 100
dwilkie Avatar answered Oct 22 '22 00:10

dwilkie


Not sure about whether you can modify it easily to only upload one file at a time, but this gem works very well for me. It is based on one of Ryan Bates' Railscast:

https://github.com/waynehoover/s3_direct_upload

like image 6
migu Avatar answered Oct 22 '22 00:10

migu