Carrierwave + Rails + Cloudfront图像返回500,rails资产正在服务

时间:2016-12-02 23:40:17

标签: ruby-on-rails amazon-s3 carrierwave amazon-cloudfront

到目前为止我有这个配置....

CarrierWave.configure do |config|
  config.fog_provider = 'fog/aws'
  config.fog_credentials = {
    provider:              'AWS',                                             # required
    aws_access_key_id:     Rails.application.secrets.s3_key,                                    # required
    aws_secret_access_key: Rails.application.secrets.s3_secret,                                 # required
    region:                Rails.application.secrets.s3_region,                                 # optional, defaults to 'us-east-1'
  }

  # For testing, upload files to local `tmp` folder.
  if Rails.env.test? || Rails.env.cucumber? #||  Rails.env.development?
    config.storage = :file
    config.enable_processing = false
    config.root = "#{Rails.root}/tmp"
  else
    config.storage = :fog
  end
  config.asset_host  = 'http://mycdn.mydomain.com'
  config.fog_directory = Rails.application.secrets.s3_bucket
  config.fog_public = true
end

http://mycdn.mydomain.com/production/uploads/1/31/dc5d27e2-bd9d-4ba5-8db2-bcbefa52be78.png

  # Override the directory where uploaded files will be stored.
  # This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    "#{Rails.env}/uploads/#{model.user_id}/#{model.id}"
  end

/ assets中的My Rails资产正在运行......这是Carrierwave正在上传我的图像的存储桶/目录,返回500错误。

例如:http://mycdn.mydomain.com/production/uploads/3/33/74b1602e-1b9c-4ffd-a53b-bba2323bdb3f.png 500(内部服务器错误)

有谁知道我的Cloudfront或S3配置中缺少什么?这可能是一个桶政策问题吗?或其他什么?

提前致谢

0 个答案:

没有答案