简体   繁体   English

使用Amazon S3时的回形针错误

[英]Paperclip error when using Amazon S3

I am migrating my application online with Heroku and Amazon AWS (S3) and encountered a weird error for my profilepic model. 我正在使用Heroku和Amazon AWS(S3)在线迁移应用程序,并且遇到了我的profilepic模型错误的错误。

This model manages the profile pic. 此模型管理个人资料照片。 It is made of 2 Paperclip attachments and a few other fields and depends to another model called Professionnel . 它由2个回形针附件和其他几个领域组成,并依赖于另一个名为Professionnel模型。

Here is the model : 这是模型:

class Profilepic < ApplicationRecord

  belongs_to :professionnel

  has_attached_file :image, styles: { original: "6000x6000", editable: "1200x1200", thumbnail: "400x400#"}
  validates_attachment :image, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }, size: {less_than: 10.megabytes}

  has_attached_file :finalimage, styles: { medium: "500x500", small: "200x200"}, processors: [:cropper]

  attr_accessor :crop_x, :crop_y, :crop_w, :crop_h

end

First attachment :image is the image uploaded by the user. 第一附件:图像是用户上传的图像。 The second image (:finalimage) is a cropped image after Professionnel user has edited it (with cropper.js) 第二个图像(:finalimage)是Professionnel用户对其进行编辑(使用cropper.js)后的裁剪图像。

Everything is working perfectly locally 一切都在本地完美运行

Though, when the image is uploaded the following bit of code is returning Paperclip::Errors::NotIdentifiedByImageMagickError 不过,上传图片时,以下代码将返回Paperclip :: Errors :: NotIdentifiedByImageMagickError

The bit of code that triggers this error is : 触发此错误的代码位是:

nouvelleppic.ratiolongdivlarg = Paperclip::Geometry.from_file(nouvelleppic.image.path(:original)).width / Paperclip::Geometry.from_file(nouvelleppic.image.path(:original)).height

In this bit of code, I am discovering the width/height ratio with help from Paperclip geometry functions. 在这段代码中,我将在Paperclip几何函数的帮助下发现宽高比。

Not sure what's wrong. 不知道怎么了。 It does work locally flawlessly and I am querying this AFTER the :image is successfully saved into my S3 bucket (I checked in S3 console) 它确实可以在本地完美地工作,并且在:image成功保存到我的S3存储桶中之后,我正在查询此信息(我在S3控制台中检查了)

I need this ratio to create the view that will allow user to crop the image and turn it into :finalimage. 我需要这个比率来创建视图,该视图将允许用户裁剪图像并将其转换为:finalimage。 This is really funny it doesn't work when migrationg to Heroku / S3 as it is a simple geometry function from Paperclip. 真的很有趣,当迁移到Heroku / S3时它不起作用,因为它是Paperclip中的简单几何函数。 No problem uploading ... 上传没有问题...

EDIT EDIT 编辑编辑

seems the problem is identified : 似乎确定了问题:

https://github.com/thoughtbot/paperclip/issues/2198 https://github.com/thoughtbot/paperclip/issues/2198

I just checked the Imagemagick version on my Heroku Cedar14 stack: 6.7.7-10 !! 我刚刚在Heroku Cedar14堆栈上检查了Imagemagick版本:6.7.7-10 !!

Version: ImageMagick 6.7.7-10 2016-11-29 Q16 http://www.imagemagick.org

as suggested in the git thread above, is there a way to upgrade ImageMagick at Heroku ?? 如上面git线程中所建议的,是否有一种方法可以在Heroku上升级ImageMagick?

This thread How can I use the latest version of Imagemagick on Heroku? 该线程如何在Heroku上使用Imagemagick的最新版本? seems to suggest we can do that (second answer) ?? 似乎建议我们可以做到(第二个答案)

In response to your second question. 回答您的第二个问题。 The way you update Image Magic on heroku is by using a buildpack. 在heroku上更新Image Magic的方法是使用buildpack。 Just like you have right now a Ruby buildpack you will have to add an Image Magic buildpack. 就像您现在拥有Ruby构建包一样,您将必须添加Image Magic构建包。 Heroku has a dedicated page for Image Magic buildpacks: Heroku有一个专门的页面用于Image Magic buildpack:

https://elements.heroku.com/search/buildpacks?utf8=%E2%9C%93&q=imagemagick https://elements.heroku.com/search/buildpacks?utf8=%E2%9C%93&q=imagemagick

This one (below) seems to be the most popular but feel free to browse around: https://elements.heroku.com/buildpacks/mcollina/heroku-buildpack-imagemagick 这个(下)似乎是最受欢迎的,但是可以随意浏览: https : //elements.heroku.com/buildpacks/mcollina/heroku-buildpack-imagemagick

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM