Skip to content

Instantly share code, notes, and snippets.

@heridev
Last active August 29, 2015 14:03
Show Gist options
  • Save heridev/61b60889e2e2d9229f7b to your computer and use it in GitHub Desktop.
Save heridev/61b60889e2e2d9229f7b to your computer and use it in GitHub Desktop.
Rails application or Spree: Uploading images and the Sitemap into amazon AWS
# we want to upload into amazon only in production mode, in development mode we are using the public local folder
#config/initializers/spree.rb
if Rails.env.production?
Spree::Image.attachment_definitions[:attachment][:path] = 'spree/products/:id/:style/:basename.:extension'
Spree::Image.attachment_definitions[:attachment][:url] = 'spree/products/:id/:style/:basename.:extension'
end
development:
VARIABLE_Y: 'heriberto.perez@crowdint.com'
VARIABLE_X: 'crowdint.com'
AWS_ACCESS_KEY_ID: youraccesskeyidgeneratedinaws
AWS_SECRET_ACCESS_KEY: yoursecretaccesskeygeneratedonamazon
FOG_PROVIDER: 'AWS'
FOG_DIRECTORY: 'yourbucketname'
production:
VARIABLE_Y: 'heriberto.perez@crowdint.com'
VARIABLE_X: 'crowdint.com'
AWS_ACCESS_KEY_ID: youraccesskeyidgeneratedinaws
AWS_SECRET_ACCESS_KEY: yoursecretaccesskeygeneratedonamazon
FOG_PROVIDER: 'AWS'
FOG_DIRECTORY: 'yourbucketname'
test:
VARIABLE_Y: ''
VARIABLE_X: ''
AWS_ACCESS_KEY_ID: ''
AWS_SECRET_ACCESS_KEY: ''
FOG_PROVIDER: 'AWS'
FOG_DIRECTORY: 'yourbucketname'
# https://github.com/laserlemon/figaro
# in our Gemfile
gem 'figaro'
rake sitemap:refresh
gem 'spree_sitemap', github: 'jdutil/spree_sitemap'
config.paperclip_defaults = {
:storage => :fog,
:fog_credentials => {
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
provider: ENV['FOG_PROVIDER']
},
fog_directory: ENV['FOG_DIRECTORY']
}
SitemapGenerator::Sitemap.default_host = "http://#{Spree::Config[:site_url]}"
## Store on S3 using Fog - Note must add fog to your Gemfile.
SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new({ aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
fog_provider: ENV['FOG_PROVIDER'],
fog_directory: ENV['FOG_DIRECTORY'] })
## Inform the map cross-linking where to find the other maps.
SitemapGenerator::Sitemap.sitemaps_host = "http://#{ ENV['FOG_DIRECTORY'] }.s3.amazonaws.com/"
SitemapGenerator::Sitemap.add_links do
add_login
add_signup
add_account
add_password_reset
add_taxons
add_products
end
Spree.config do |config|
config.site_name = 'Ecommerce consultancy'
config.site_url = ENV['SITE_URL'] || 'crowdint.com'
end
# in our Gemfile
gem "paperclip"
# https://github.com/fog/fog
# in our Gemfile
gem 'fog', '~> 1.22.0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment