3

我已经升级到 rails 5.2 并且正在实施 ActiveStorage。ActiveStorage 使用 mutool 进行 PDF 处理。我已经使用自制软件在本地成功安装了 mutool。

mutool is a bit confusing.  

rails docs claim to require "mutool", 
homebrew installs "mupdf-tools", 
and heroku wants "mupdf".

我已经按照以下步骤在heroku上成功安装了apt和mupdf:

- add a new Aptfile to the root of my application with only "mupdf" listed
- commit and push the Aptfile
- THEN run heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
- push again so heroku will finish installing apt and mupdf

mupdf 在推送期间构建成功

heroku buildpacks now returns    
1. https://github.com/heroku/heroku-buildpack-apt
2. heroku/ruby

如果我刷新页面以调用 PDF 上的变体,则图像无法处理并且作业会返回以下错误:

  Errno::ENOENT: No such file or directory - mutool

似乎 mutool 和 mupdf 是同义词...所以,我尝试在我的 Aptfile 中将 mutool 换成 mupdf...未能从“...未找到”构建。

有人知道我需要采取什么行动吗?

PS:这是使用 ActiveStorage 实现 rails 5.2 的一部分。

更新

我将 mupdf-tools 添加到 Aptfile 中,这似乎解决了“没有这样的文件或目录”错误。我不确定,因为出现了新的错误

MiniMagick::Invalid: `identify /tmp/mini_magick20180105-4-pvub9r` failed with error: identify.im6: no decode delegate for this image format `/tmp/mini_magick20180105-4-pvub9r' @ error/constitute.c/ReadImage/544.

MiniMagick::Error: `identify -format %m %w %h %b /tmp/ActiveStorage20180105-4-1f46tem[0]` failed with error: identify.im6: no decode delegate for this image format `/tmp/ActiveStorage20180105-4-1f46tem' @ error/constitute.c/ReadImage/544.
4

2 回答 2

4

Heroku 出于许可原因推荐 Poppler 作为 MuPDF 的替代品(MuPDF 具有商业许可)。

他们为 Active Storage Previews 创建了一个 buildpack,涵盖 PDF 和视频文件。

于 2018-05-15T22:49:15.343 回答
2

我知道这有点老了,但如果你仍然遇到这个问题,我可以通过将 mupdf-tools 的版本更新到至少 1.8 来解决这个问题。

要使用 Heroku 执行此操作,您需要直接链接到最新版本。

添加heroku-buildpack-apt,然后添加自定义 Aptfile。请注意,您需要先添加 Aptfile 才能使 buildpack 工作。

这是我的 Aptfile 的样子:

:repo:deb http://archive.ubuntu.com/ubuntu artful main universe
imagemagick
ffmpeg
mupdf-tools

要测试您是否拥有正确的版本,您可以使用heroku ps:exec测试。运行mutool -v,您应该使用 1.11 版。

于 2018-03-15T04:31:57.080 回答