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
end

3)
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
4)
use IAM user Access Credentials

Reference

1) https://guides.spreecommerce.com/developer/s3_storage.html
2)https://devcenter.heroku.com/articles/paperclip-s3

About http://www.infosolutions.klairvoyant.com/

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

Leave a comment