sitemap_generator和Carrierwave - 更改S3权限,但只是暂时的

时间:2014-06-27 18:56:10

标签: ruby-on-rails carrierwave fog sitemap-generator-gem

我正在使用带有carrierwavesitemap_generator的Rails 3.2。

文件已正确上传,但S3上的权限不公开。

  • 如何设置此" sitemap.xml.gz"的权限?仅限文件?

我的S3 Bucket通常只对令牌开放:

CarrierWave.configure do |config|

  config.storage = :fog

  config.fog_credentials = {
      :provider => 'AWS', # required
      :aws_access_key_id => ENV['S3_KEY'],
      :aws_secret_access_key => ENV['S3_SECRET']
  }
  config.fog_directory = ENV['S3_BUCKET_NAME']

  # -> THIS is what sitemap_generator likes: 
  # -> config.permissions = "0666"
  # here I set my permissions:
  config.fog_public = false
  config.fog_attributes = {'Cache-Control' => 'max-age=315576000'}
end

我的sitemap_generator gem initalizer是:

# WaveAdapter: carrierwave
SitemapGenerator::Sitemap.adapter = SitemapGenerator::WaveAdapter.new

SitemapGenerator::Sitemap.sitemaps_host = "http://s3.amazonaws.com/#{ENV['S3_BUCKET_NAME']}/"

SitemapGenerator::Sitemap.public_path = 'tmp/'

SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/'

谢谢!

1 个答案:

答案 0 :(得分:0)

看起来config.fog_public设置为false;您应该将其设置为true以在S3上启用公共查看。