-
-
Save achalbi/cc7049decedd63120cf2a11e532effd0 to your computer and use it in GitHub Desktop.
Solidus config for S3 file upload + CDN (Cloudfront) delivery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Upload new product images to S3 and deliver via Cloudfront | |
Spree.config do |config| | |
attachment_config = { | |
s3_credentials: { | |
access_key_id: ENV.fetch("S3_ACCESS_KEY"), | |
secret_access_key: ENV.fetch("S3_SECRET"), | |
bucket: ENV.fetch("S3_BUCKET"), | |
}, | |
storage: :s3, | |
s3_headers: { "Cache-Control" => "max-age=31557600" }, | |
s3_protocol: "https", | |
url: ':s3_alias_url', | |
s3_host_alias: 'xxxx.cloudfront.net', | |
bucket: ENV.fetch("S3_BUCKET"), | |
styles: { | |
mini: "48x48>", | |
small: "100x100>", | |
product: "240x240>", | |
large: "600x600>" | |
}, | |
path: "/products/:id/:style/:basename.:extension", | |
default_url: "/products/:id/:style/:basename.:extension", | |
default_style: "product", | |
} | |
attachment_config.each do |key, value| | |
Spree::Image.attachment_definitions[:attachment][key.to_sym] = value | |
end | |
end unless Rails.env.test? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment