2

I had successfully integrated comfortable mexican sofa CMS into an existing rails 4.1.2 application.

Now I want to upload images to heroku from s3 bucket.

Can anyone please tell the steps for that?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278

3 Answers3

3

Sofa is using paperclip for attachments. So first, take a look here: http://www.rubydoc.info/gems/paperclip/Paperclip/Storage/S3

Then in initializers/comfortable_mexican_sofa.rb you'll find config.upload_file_options. This is how you'll override defaults.

config.upload_file_options = {
  :storage        => :s3,
  :s3_credentials => ...
}
Grocery
  • 2,244
  • 16
  • 26
  • Thank you.......... The quality of images which is uploaded to heroku through s3 bucket decease to localhost can you please tell me how change to its original image quality – Harshith Prasad Feb 18 '15 at 11:51
  • Take a look here: https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation It mentions how to control thumbnail quality. Never tried it myself. – Grocery Feb 18 '15 at 20:25
  • Thank you for your guidance.. please don't mind I just did like this :styles => { :medium => "300x300>", :thumb => "100x100>" } this is what you are saying – Harshith Prasad Feb 19 '15 at 05:46
3
config.upload_file_options = {
  :whiny => false,
  :storage => :s3,
  :s3_credentials => {"access_key_id" => ENV["S3_ACCESS_KEY_ID"], "secret_access_key" => ENV["S3_SECRET_ACCESS_KEY"]},
  :bucket => ENV["S3_BUCKET_NAME"], 
  :s3_host_name => 's3 HOST NAME',
  :path => "uploaded_files/:basename.:extension",
  :styles => {:thumb => "850x850>" }
  }

Give styles inside the config.upload_file_options which will take exact size of an image.

Which make more sense in uploading image else image pixels may vary.

The available configuration parameters are defined in paperclip, not comfy, and more information about there meaning can be found at:

http://www.rubydoc.info/github/thoughtbot/paperclip/Paperclip/Storage/S3

agbodike
  • 1,796
  • 18
  • 27
0

Just a note: Comfy has switched from Paperclip to ActiveStorage in 2017, so the answers are somewhat outdated.

Alex A.
  • 845
  • 8
  • 10