使用Shrine上传到S3的图像即时创建MiniMagick Montage

我正在尝试创建一个蒙太奇文件,该文件包含通过Shrine(私下)上传到S3的各种缩略图。

此操作的代码驻留在Sidekiq工作程序(在Heroku中)中,该工作程序应发送带有上面处理的图像的电子邮件作为电子邮件附件。 (然后只是转储图像)

这是我的尝试:

images = []

@user.photos.first(25).each do |photo|
  images << File.read(photo.image[:thumb].url)
end

processed_image = MiniMagick::Tool::Montage.new do |image|
        images.each {|i| image << i} 
        image.tile "5x5"
        image << "output.jpg"        
end

attachments.inline['images.jpg'] = processed_image

尽管出现错误:

  

2019-11-04T18:17:59.638Z 30695 TID-ot0uksdbv警告:Errno :: ENOENT:否   这样的文件或目录@ rb_sysopen-   https://mysite.s3.eu-west-1.amazonaws.com/photo/thumb/5cb924406fa8944e5279a15b46f250f6.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIJJCEGJCEVP2A%2F20191104%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20191104T181759Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=38706b7526fd0a8095a2f387521063d4d8901c4523696ff7e1f60ae2d

似乎无法在S3处打开拇指(我混淆了上面的链接,但是当粘贴到浏览器中时,它会正确返回图像)

我试图直接在块中传递链接:

images << photo.image[:thumb].url

但是这次看来我从MiniMagick那里得到了错误

  

montage-im6.q16:未授权HTTPS' @ error/delegate.c/InvokeDelegate/1717. montage-im6.q16: unable to open file':无此类文件或目录@ error / constitute.c / ReadImage / 544。   montage-im6.q16:未经授权HTTPS' @ error/delegate.c/InvokeDelegate/1717. montage-im6.q16: unable to open file':不允许操作@ error / constitute.c / ReadImage / 544。   montage-im6.q16:未经授权HTTPS' @ error/delegate.c/InvokeDelegate/1717. montage-im6.q16: unable to open file':不允许操作@ error / constitute.c / ReadImage / 544。   montage-im6.q16:未经授权HTTPS' @ error/delegate.c/InvokeDelegate/1717. montage-im6.q16: unable to open file':不允许操作@ error / constitute.c / ReadImage / 544。   montage-im6.q16:未经授权的HTTPS @   错误/delegate.c/InvokeDelegate/1717。

不太确定如何处理。.

hgy1111 回答:使用Shrine上传到S3的图像即时创建MiniMagick Montage

在处理之前,您需要将文件下载到磁盘,并在montage命令中使用本地路径。另外,由于montage命令仅返回标准输出,因此您需要从输出路径读取结果文件。

它们看起来可能像这样:

Traceback (most recent call last):

  File "<ipython-input-35-495ebeb2207b>",line 1,in <module>
    big_tree.xpath("//*[self::foo or self::bar]/test/entry")

  File "src/lxml/etree.pyx",line 2287,in lxml.etree._ElementTree.xpath

  File "src/lxml/xpath.pxi",line 359,in lxml.etree.XPathDocumentEvaluator.__call__

  File "src/lxml/xpath.pxi",line 227,in lxml.etree._XPathEvaluatorBase._handle_result

XPathEvalError: Error in xpath expression
本文链接:https://www.f2er.com/3164444.html

大家都在问