3

My rails 4 app is using an Amazon s3 bucket to store images. The configuration is pretty default with my production.rb file looking like this

config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['S3_BUCKET_NAME'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
  }
}

When the page loads an image, it loads it like this:

http://s3.amazonaws.com/themoderntrunk/designs/photos/000/000/052/large_thumbnail/product12.jpeg?1389721666

I wish for it to load with the prefix https:

https://s3.amazonaws.com/themoderntrunk/designs/photos/000/000/052/large_thumbnail/product12.jpeg?1389721666    

without the SSL, my app is getting the warning in the console

he page at 'https://www.themoderntrunk.com/assortments/4/designs/52-product-12' was loaded over HTTPS, but displayed insecure content from 'http://s3.amazonaws.com/themoderntrunk/designs/photos/000/000/049/grid/product9.jpg?1389721643': this content should also be loaded over HTTPS.

Granted, in my production.rb file I have config.forse_ssl = true. My app also has SSL certificate.

Justin
  • 4,922
  • 2
  • 27
  • 69

1 Answers1

8

You need to add it in the model

class Designs < ActiveRecord::Base
  has_attached_file :photo, :s3_protocol => :https

Ref: Is it possible to configure Paperclip to produce HTTPS urls?

Community
  • 1
  • 1
Andrew Wei
  • 2,020
  • 1
  • 17
  • 28