How to Store Spree Images on AWS S3
A concern for some Spree users is that the backend no longer gives you the option to configure s3 for storing images. Fortunately, there is now a workaround which we’ll detail in this blog post.
The first step is to add AWS-SDK to your gemfile with this command: gem ‘aws-sdk’. Once you’ve done that, install the gem by running bundle install.
Once you’ve completed that, you’ll need to configure Spree to use s3. You can add an initializer, or just use the spree.rb intitializer, which can be found at config/initilizers/spree.rb.
It’s important to recognize that the url: “:s3_domain_url” setting is used in order to enable the DNS lookup for your images, without specifying the specific zone endpoint. You would need to use a bucket name that makes the subdomain valid. Don’t use dots if you’re planning on using the DNS lookup configuration.
About the Author
Peter is an early Spree adopter. He launched his first Spree Commerce storefront for a client back in 2008. Since then he has written a number of Spree extensions and contributed a lot to the Spree open source community. Since July, 2013 Peter has worked full time on the Spree open source stack and supports customers on the edge of Wombat and the Spree storefront code. You can access this blog in its original format on his website.