【发布时间】:2017-04-24 10:05:43
【问题描述】:
正如标题所示,我使用的是回形针和带有 Rails 的 S3。当我尝试创建包含图像的记录时,我收到此错误:
[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 ():
我不知道发生了什么,除了“它不工作”......
这是我的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/
【问题讨论】:
标签: ruby-on-rails amazon-s3 paperclip ruby-on-rails-5