Skip to content

Instantly share code, notes, and snippets.

@traels
Created July 1, 2014 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save traels/941ec9e865786484650e to your computer and use it in GitHub Desktop.
Save traels/941ec9e865786484650e to your computer and use it in GitHub Desktop.
Spree 2.2 image on S3
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => 'BUCKET',
:access_key_id => 'S3_KEY',
:secret_access_key => 'S3_SECRET'
}
}
Paperclip::Attachment.default_options[:s3_protocol] = "https"
Spree::Image.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode('{"mini":"48x48\u003E","small":"100x100\u003E","product":"240x240\u003E","large":"600x600\u003E"}').symbolize_keys!
Spree::Image.attachment_definitions[:attachment][:path] = " /#{Rails.env}/:id/:style/:basename.:extension"
Spree::Image.attachment_definitions[:attachment][:url] = '/spree/products/:id/:style/:basename.:extension'
Spree::Image.attachment_definitions[:attachment][:default_url] = ''
Spree::Image.attachment_definitions[:attachment][:default_style] = 'product'
@traels
Copy link
Author

traels commented Jul 1, 2014

Not pretty, but working.
I have Rails.env in my path so I can use same bucket for all environments.
I can see that I've left out s3_host_alias, that is an error, will haunt men when I deploy this to my .eu version of the store, that uses an EU S3 bucket for images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment