当我使用Active Storage时,当有人上载.webp映像时,并且当我运行file.attach(io: webp_file, filename: 'file.webp')
时,它可以工作,然后ActiveStorage自动运行作业ActiveStorage::AnalyzeJob
但是这项工作引起了人们的注意:
MiniMagick::Error (`identify -format %[orientation] /tmp/ActiveStorage-114989-20180905-4-wak8ob.webp[0]` failed with error:
identify-im6.q16: delegate failed `'dwebp' -pam '%i' -o '%o'' @ error/delegate.c/InvokeDelegate/1919.
identify-im6.q16: unable to open file `/tmp/magick-1400SWBHj-p67HrV': No such file or directory @ error/constitute.c/ReadImage/544.
尽管我在Heroku-18上,所以有一个名为“ libwepb6”(https://devcenter.heroku.com/articles/stack-packages)的库
我必须创建一个Heroku buildpack吗?
答案 0 :(得分:1)
有同样的问题。这是逐步的:
1-将其添加到development.rb和production.rb中以强制Rails接受WEBP。
config.active_storage.variable_content_types = %w(
image/png
image/gif
image/jpg
image/jpeg
image/webp
image/vnd.adobe.photoshop
image/vnd.microsoft.icon
)
2-将this buildpack添加到heroku上的应用程序中,确保它是第一包。它允许您安装尚未预先安装的ubuntu软件包。
3-导航至应用程序的根目录(您的Gemfile所在的位置),然后运行以下命令来创建名为AptFile
的文件,并向其中添加webp
软件包。
touch Aptfile
echo "webp" >> Aptfile
4-重新部署您的应用。
Heroku现在将安装imagemagick处理webp图像所需的缺少的webp
软件包。
答案 1 :(得分:-1)
编辑:因此正在使用S3,并使用/tmp
进行操作。
看着错误,似乎可以将其委托给dwebp
,所以我必须假定它是正确构建的。如果不是使用webp构建的,则会出现类似这样的委托错误
identify.im6: no decode delegate for this image format `1.sm.webp' @ error/constitute.c/ReadImage/544.
您可以通过运行heroku run "identify -list format | grep -i WebP"
该错误似乎与/tmp/
文件目录访问有关。
空间状况如何? df -h
请注意,在Mac上,我注意到了/var
目录的使用:
~/w/p ❯❯❯ identify 1.sm.webp
Decoded /var/folders/lk/z_bvyjj939d94mvkx6rz9700fbx9gg/T/magick-99980zzj1IT0Lkx7L. Dimensions: 320 x 214 . Format: lossy. Now saving...
Saved file /var/folders/lk/z_bvyjj939d94mvkx6rz9700fbx9gg/T/magick-999803WU_TvRo7xdJ
1.sm.webp PAM 320x214 320x214+0+0 8-bit TrueColor sRGB 273989B 0.000u 0:00.000
这位heroku员工可能对此有更多了解。
本文还详细介绍了https://devcenter.heroku.com/articles/active-storage-on-heroku,尤其是这一点:
使用:local选项存储的文件上传将会出现 刚开始工作时,附件会表现出看似奇怪的状态 行为并最终消失。
有关使用云存储(例如Amazon S3)的建议。