我曾尝试在线阅读很多东西,但都没有帮助。所以需要一个具体的答案。我如何配置S3以使用Spree? 我正在使用Spree 3.0.1和Rails 4.2.1。如何使用Spree设置Amazon S3?
我已经spree.rb为:
Spree.config do |config|
# Example:
# Uncomment to override the default site name.
# config.site_name = "Gazella Running Costumes"
# config.logo = "store/rungazella.png"
#S3 configuration
if Rails.env.production? then
#production. Store images on S3.
# development will default to local storage
attachment_config = {
s3_credentials: {
access_key_id: ENV["S3_KEY"],
secret_access_key: ENV["S3_SECRET"],
bucket: ENV["S3_BUCKET"],
},
storage: :s3,
s3_headers: { "Cache-Control" => "max-age=31557600" },
s3_protocol: "https",
bucket: ENV["S3_BUCKET"],
path: ":rails_root/public/:class/:attachment/:id/:style/:basename.:extension",
default_url: "/:class/:attachment/:id/:style/:basename.:extension",
default_style: "product",
}
attachment_config.each do |key, value|
Spree::Image.attachment_definitions[:attachment][key.to_sym] = value
end
end
Spree.user_class = "Spree::User"
end
也是我的Gemfile是
source 'https://rubygems.org'
gem 'rails', '4.2.1'
ruby '2.2.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
gem 'spree', '3.0.1'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem 'rails_12factor', group: :production
gem 'pg'
gem 'aws-sdk'
你使用回形针宝石处理图像? –
是的,我正在使用回形针。 –
你有解决方案吗?我正在努力解决这个问题,并且无法正常工作 –