0

I need to download an image and save it to my database. Im new to Ruby on Rails. What is the best way to do this? I will have the image URL at my disposal. Also whats the best column type in my table to store the image?

Deekor
  • 9,144
  • 16
  • 69
  • 121
  • Might want to check http://stackoverflow.com/questions/1471165/download-an-image-and-save-it?rq=1 and http://stackoverflow.com/questions/2515931/i-want-to-download-a-file-from-a-url-to-save-it-any-rails-way-to-do-this-or-can?rq=1 – pyrometer Jul 14 '12 at 23:08

1 Answers1

0

Check out this blog post entitled "Paperclip sample app part 3: saving file attachments in a database BLOB column"

Dty
  • 12,253
  • 6
  • 43
  • 61
  • now that I'm thinking about it, do I want to save it to the database if im going to use it on my page, or would it be better to save it to the disk? – Deekor Jul 15 '12 at 22:18
  • The article goes through the different reasons for saving it to the database vs disk. But usually people want to save it to disk. However, if you're using Heroku for hosting then you'll need to save it to a service like Amazon S3. – Dty Jul 16 '12 at 00:41
  • will paperclip allow me to save to Amazon? – Deekor Jul 16 '12 at 03:57
  • 1
    seems like a lot of people prefer carrierwave over paperclip. https://github.com/jnicklas/carrierwave see the docs for using it with Amazon S3 – Dty Jul 16 '12 at 08:36