我正在使用带有carrierwave
and的 Rails 3.2 sitemap_generator
。
该文件已正确上传,但权限在 S3 上不公开。
- 如何仅设置此“sitemap.xml.gz”文件的权限?
我的 S3 存储桶通常只对令牌开放:
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/'
谢谢!