Sha256: 3df8dce2d459b88b456b97ad1556c7496911c232dcd54b10e2ab5599821bf7cf

Contents?: true

Size: 714 Bytes

Versions: 2

Compression:

Stored size: 714 Bytes

Contents

require 'fog'

module SitemapGenerator
  class S3Adapter

    # Call with a SitemapLocation and string data
    def write(location, raw_data)
      SitemapGenerator::FileAdapter.new.write(location, raw_data)
      
      credentials = { 
        :aws_access_key_id     => ENV['AWS_ACCESS_KEY_ID'],
        :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
        :provider              => ENV['FOG_PROVIDER'],
      }
      
      storage   = Fog::Storage.new(credentials)
      directory = storage.directories.get(ENV['FOG_DIRECTORY'])
      directory.files.create(
        :key    => location.path_in_public, 
        :body   => File.open(location.path),
        :public => true
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitemap_generator-3.3 lib/sitemap_generator/adapters/s3_adapter.rb
sitemap_generator-3.2.1 lib/sitemap_generator/adapters/s3_adapter.rb