gpt4 book ai didi

ruby-on-rails - Rails s3 桶 SSL

转载 作者:太空宇宙 更新时间:2023-11-03 12:56:37 25 4
gpt4 key购买 nike

我的 Rails 4 应用程序使用 Amazon s3 存储桶来存储图像。配置非常默认,我的 production.rb 文件看起来像这样

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']
}
}

当页面加载图片时,它会像这样加载它:

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

我希望它加载前缀为 https:

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

没有 SSL,我的应用程序在控制台中收到警告

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.

当然,在我的 production.rb 文件中我有 config.forse_ssl = true。我的应用程序也有 SSL 证书。

最佳答案

需要在模型中添加

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

引用:Is it possible to configure Paperclip to produce HTTPS urls?

关于ruby-on-rails - Rails s3 桶 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21122199/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com