Paperclip,S3,Rails-Aws :: S3 :: Errors :: InvalidArgument():

时间:2016-12-09 01:33:42

标签: ruby-on-rails amazon-s3 paperclip ruby-on-rails-5

正如标题所示,我使用回形针和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 ():

我不知道发生了什么,除了"它没有工作" ......

这是我的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/

1 个答案:

答案 0 :(得分:1)

检查您的packageName,此选项的值应该是here的“预设ACL”权限之一。 Service似乎不是一个选项!