configure S3 in spree, Heroku

1) add gem ‘aws-sdk’ and then bundle install.

add to spree.rb located at config/intializers/spree.rb. you don’t want to change anything in this code

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: “48×48>”,
small: “100×100>”,
product: “240×240>”,
large: “600×600>”

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

Additionally, we’ll need to the set the AWS configuration variables on the Heroku application.
$ heroku config:set S3_BUCKET_NAME=your_bucket_name
$ heroku config:set AWS_ACCESS_KEY_ID=your_access_key_id
$ heroku config:set AWS_SECRET_ACCESS_KEY=your_secret_access_key
use IAM user Access Credentials



This entry was posted in ecommerce, web development and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s