sitemap_generator and Carrierwave - Change S3 permission, but only temporarily

215 views Asked by At

I am using Rails 3.2 with carrierwave and sitemap_generator.

The file is correctly uploaded, but the permissions are not public on S3.

  • How can I set the permission for this "sitemap.xml.gz" file only?

My S3 Bucket is normally only open for tokens:

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

and my sitemap_generator gem initalizer is:

# 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/'

Thank you!

1

There are 1 answers

0
AudioBubble On

It looks like the config.fog_public is set to false; you should set it to true to enable public viewing on S3.