Paperclip::Error,处理缩略图时出错

Paperclip::Error, There was an error processing the thumbnail

我正在使用回形针、imagemagick、rmagick 将图像上传到 s3。以前,图片上传功能在 ruby 1.9.3'rails', '3.2.11' 上运行良好。升级 ruby 2.0.0'rails', '4.0.3' 后出现错误。

在store.rb

#paperclip
has_attached_file :logo,
styles: {
  thumb: ["40x40#", :png],
  small: ["400x400>", :png],
  masked_with_overlay: ["288x64", :png],
  masked_with_nearby_overlay: ["238x47#", :png],
  masked_with_rewards_overlay: ["288x64", :png],
  masked_with_overlay_for_old: ["288x64", :png],
  masked_with_nearby_overlay_for_old: ["238x47#", :png],
  masked_with_rewards_overlay_for_old: ["288x64", :png],
  masked_full_card_image: ["576x128", :png],
  masked_logo_only: ["576x128", :png]
},
convert_options: { masked_with_overlay: Proc.new{self.apply_mask_and_overlay},
  masked_with_nearby_overlay: Proc.new{self.apply_mask_and_nearby_overlay},
  masked_with_rewards_overlay: Proc.new{self.apply_mask_and_rewards_overlay},
  masked_with_overlay_for_old: Proc.new{self.apply_mask_and_overlay_for_old},
  masked_with_rewards_overlay_for_old: Proc.new{self.apply_mask_and_rewards_overlay_for_old},
  masked_full_card_image: Proc.new{self.apply_mask_full_card_image},
  masked_logo_only: Proc.new{self.apply_mask_logo_only}

},
storage: :s3,
s3_credentials: "#{Rails.root}/config/s3.yml",
path: "/store_logos/:style/:id/:filename"

validates_attachment :logo, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/JPG", "image/JPEG", "image/PNG"] }

这里是 Gemfile

ruby '2.0.0'
gem 'rails', '4.0.3'
gem 'aws-s3'
gem 'aws-sdk', '~> 1.5.7'
gem 'paperclip', "~> 4.2"
gem 'rmagick', '2.13.2'

stores_controller.rb

class StoresController < ApplicationController
  def update

   if !params[:store].nil? && !params[:store][:store_owner].nil?
    params[:store][:store_owner][:email] = params[:store][:store_owner][:email].downcase
   end

   if params[:demo_store_changes]
     params[:store][:active] = false
   else
     params[:store][:store_hours] = params[:store][:store_hours].to_json
     params[:store][:minimum_seconds_per_scan] = (params[:store][:minimum_seconds_per_scan]).to_i * 3600
   end

  @store.store_owner.store_owner!

  if params[:store][:scanning_distance].blank?
    params[:store].delete :ms
  else
    if params[:store][:location_check]
      if params[:store][:ms] == "mi"
        params[:store][:scanning_distance] = ( params[:store][:scanning_distance].to_f * 5280 )
        params[:store].delete :ms
      else
        params[:store][:scanning_distance] = params[:store][:scanning_distance].to_f
        params[:store].delete :ms
      end
    end
  end

  if @store.update_attributes(store_params) and @store.build_categories(params[:category_ids].to_a)
   if params[:demo_store_changes]
     demo_message = @store.demo ? " is now demo store" : " is not a demo store anymore"
     flash[:notice] = @store.name + demo_message
     redirect_to stores_path('store[search]'=> params[:store_search], search_value: params[:search_value])
   else
     @password_chk=params[:store][:store_owner_attributes][:password] 
     redirect_to "#{store_path()}?myid=#{session[:bread_crum]}", notice: (I18n.t :update_store_success)
   end
 else
   @store.store_hours = ActiveSupport::JSON.decode(@store.store_hours)
   if @store.minimum_seconds_per_scan?
     @store.minimum_seconds_per_scan = (@store.minimum_seconds_per_scan / 3600).to_i
   end
   @categories = Category.all.sort
   @states = StoreConstants::STATES.sort
   @main_location_stores = Store.with_no_branch(@store.id)
   flash.now[:error] = (I18n.t :update_store_failed)
   render action: "edit"
 end

 private
 def store_params
   params.require(:store).permit!
 end
end

这里是log

有什么帮助吗?提前致谢

查看日志 (:bucket_name=>"punchme-co-dev",:key=>"store_logos/masked_with_rewards_overlay/96/Casablanca.png") AWS::S3::Errors::NoSuchKey 没有这样的键) AWS 访问密钥正在使用您的图像文件路径。

我终于找到了解决办法。

convert: no decode delegate for this image format `/home/likewise-open/ANNETSITE/1820/RailsWorkspace/Punchme_web_Test' @ error/constitute.c/ReadImage/532.
convert: unable to open image `Builds/app/assets/images/card_overLay.png':  @ error/blob.c/OpenBlob/2587.

通过将项目文件夹 Project_web_Test Builds 重命名为 Project_web_Test_Builds,当您处理图像时 space 是不允许的。