Rails uploading multiple photos onto Amazon S3 - ruby-on-rails

I currently use the Paperclip gem to attach photos onto certain models in my project. However, I have a blog model where I use multiple photos per instance of the blog.
I'm looking for a solution where I can just upload photos into a folder on Amazon S3 and refer to these photos later using the HTML anchor tags. I don't want to attach the photos to any model.
Any suggestions?

I haven't done this myself, but I would look for the solution here http://amazon.rubyforge.org/ I believe paperclip uses it behind the hood.

Related

upload image to cloudinary and save only the url in database

I want to create a photo gallery in Rails displaying the photos from Cloudinary. How to save the urls in the database to display them, or is there any other option to do it without saving the urls?
Many Thanks,
Imre
Cloudinary has a pretty good documentation on how to integrate its service into a Rails app. Start by adding the gem to your gem file.
http://cloudinary.com/documentation/rails_integration
What you describe: "...save only url to the Database' is basically the principle of their service. You save the image itself in their cloud and the gem provides you a #model.name_url helper inside your app as well as a url for the image.
They offer different options of setting up their cloud service with Ruby and Rails, and much can be found in their docs.
Cloudinary also has a good Doc on how to integrate carrierwave and cloudinary together for image upload.
http://cloudinary.com/documentation/rails_carrierwave

Best approach to Users Profile Images in Rails App

I am new to Rails and have been diving into many tutorials and online material. I am now beginning to plan/develop my own app. From all the reading I have done I am yet to come across an industry standard way of handling user profile pictures. I have bullet point what I intend to do (below) and would like some suggestions whether this is a good approach and on the right track or whether there is a much better/secure/standard way:
add a 'ProfilePhotoPath' column to my User Model/Table of type String, which will hold the location path/name of the photo
on sign-up form implement an image upload functionality to upload profile pic and store at specified location (reference in step 1 above)
note: I have come across the 'paperclip gem' and 'imagemagick', is this a better easier approach to what I want to achieve?
There are two better ways to upload profile image using Carrierwave or Paperclip.
If you want to use Carrierwave then refer this tutorial Image Upload using Carrierwave
And if you want to go for Paperclip, then refer this links Upload image using Paperclip video tutorial
Another link with steps is Upload profile image using Paperclip
Most people use Paperclip or a more robust solution would be Carrierwave.
Both are really good. I would tell you to learn Paperclip first.
It's fairly easy if you're just starting out.
Edit: checkout this link. Click the green 'run' button to see the app.
http://runnable.com/UnnhcBiQoFhwAAEb/how-to-upload-files-using-paperclip-for-ruby-on-rails

Uploading directly to S3 and resizing the images

I'm using s3_direct_upload to directly upload images from my rails app to an S3 bucket. This is all working fine, however now I'd like to resize the images once uploaded, creating a thumbnail and various other versions.
The approach I can think of taking is using the URL that's posted back from s3_direct_upload to then create a new object in my app in the background, process using RMagick and then reupload these versions to S3. However, this approach feels like the initial upload becomes a little redundant.
Any advice on this or a better approach would be greatly appreciated.
Updated Answer
You mentioned in a comment to my original answer that you'd tried CarrierWave. But...have you tried out CarrierWaveDirect? I haven't used it myself, but it appears to perform the same S3 direct-uploading, with the familiar API of CarrierWave.
Original Deprecated Answer
You'll probably want to look into either Paperclip or Dragonfly. They each support uploading images to S3 (or other cloud storage provider), and also provide features for manipulating the images. The two solutions handle manipulations in different ways--Paperclip performs thumbnailing at upload-time, whereas Dragonfly performs thumbnailing on-the-fly--but either should meet your needs.

making the images secure so as to make it not accessed by others

I use paperclip gem to store images to s3 and it is displayed with the url of amazon. What i need is, i want to store images in s3 and i want only the users to view the images by using the url. Now if the url is known the image can be accessed anywhere. So how can this be restricted?
There is a very detailed description of how to do this on the paperclip wiki on Github:
check here. Just provide the links created in that way only to users with permission and it should work fine.

uploading to google drive with paperclip in Rails

Hello there i am new to using the google drive gem and i do not know how to use it with paperclip to upload photos to the google drive. Its a simple rails application that i am developing that uploads photos to google drive, is there any rails application example that i can use to get me started with the gem or can any body present an example here to aid we beginners using the google drive gem. Paperclip should be used to upload the files. Thank You
You'd likely have to implement a storage adapter for Paperclip. Take a look at something like https://github.com/dripster82/paperclipdropbox as an example. In that case, it looks like it only supports uploading to a single pre-authorized account. If that's OK, then modifying that to talk to Google Drive instead of Dropbox should be straightforward. If you need to support multiple users, you'd have to make sure the right credentials are being used for the current user.
Anyway, the paperclip docs are likely the best place to get started :)

Resources