Skip to content

Instantly share code, notes, and snippets.

@peterberkenbosch
Created August 25, 2014 15:47
Show Gist options
  • Save peterberkenbosch/f5be9e65022cd33d3fba to your computer and use it in GitHub Desktop.
Save peterberkenbosch/f5be9e65022cd33d3fba to your computer and use it in GitHub Desktop.
Use S3 to store images with Spree
attachment_config = {
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET_NAME']
},
storage: :s3,
s3_headers: { "Cache-Control" => "max-age=31557600" },
s3_protocol: "https",
bucket: ENV['S3_BUCKET_NAME'],
url: ":s3_domain_url",
styles: {
mini: "48x48>",
small: "100x100>",
product: "240x240>",
large: "600x600>"
},
path: "/spree/:class/:id/:style/:basename.:extension",
default_url: "/spree/:class/:id/:style/:basename.:extension",
default_style: "product"
}
attachment_config.each do |key, value|
Spree::Image.attachment_definitions[:attachment][key.to_sym] = value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment