回形针,S3,Rails—Aws::S3::Errors::InvalidArgument ():
Paperclip, S3, Rails—Aws::S3::Errors::InvalidArgument ():
如标题所示,我将回形针和 S3 与 Rails 一起使用。当我尝试创建包含图像的记录时,出现此错误:
[paperclip] saving interactives/5/images/original/Havaneser_Anton.jpg
(6.6ms) ROLLBACK
Completed 500 Internal Server Error in 2021ms (ActiveRecord: 86.8ms)
Aws::S3::Errors::InvalidArgument ():
我不知道发生了什么,除了 "It's not working"...
这是我的 development.rb
配置:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.paperclip_defaults = {
storage: :s3,
s3_permissions: :public,
s3_region: ENV['AWS_REGION'],
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['AWS_S3_BUCKET']
},
s3_protocol: 'https',
s3_host_name: "s3-#{ENV['AWS_REGION']}.amazonaws.com",
path: ":class/:id/:attachment/:style/:filename"
}
我的模型是这样的:
class Interactive < ApplicationRecord
belongs_to :project
has_attached_file :image, styles: { low_res: "10%", medium: "300x300>", thumb: "300x250>" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
检查您的 s3_permissions: :public
,该选项的值应该是 here 的 "Canned ACL" 权限之一。 :public
似乎不是一个选项!
如标题所示,我将回形针和 S3 与 Rails 一起使用。当我尝试创建包含图像的记录时,出现此错误:
[paperclip] saving interactives/5/images/original/Havaneser_Anton.jpg
(6.6ms) ROLLBACK
Completed 500 Internal Server Error in 2021ms (ActiveRecord: 86.8ms)
Aws::S3::Errors::InvalidArgument ():
我不知道发生了什么,除了 "It's not working"...
这是我的 development.rb
配置:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.paperclip_defaults = {
storage: :s3,
s3_permissions: :public,
s3_region: ENV['AWS_REGION'],
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['AWS_S3_BUCKET']
},
s3_protocol: 'https',
s3_host_name: "s3-#{ENV['AWS_REGION']}.amazonaws.com",
path: ":class/:id/:attachment/:style/:filename"
}
我的模型是这样的:
class Interactive < ApplicationRecord
belongs_to :project
has_attached_file :image, styles: { low_res: "10%", medium: "300x300>", thumb: "300x250>" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
检查您的 s3_permissions: :public
,该选项的值应该是 here 的 "Canned ACL" 权限之一。 :public
似乎不是一个选项!