活动存储:无法创建视频附件的图像预览

我有一个带有视频活动存储附件的Rails模型。现在,当我想为该附件创建图像预览时,看似已创建了预览,但是结果是视频,而不是应有的图像。尽管代码没有更改,但整个过程一直持续到最近。我的代码如下所示:

class MyModel < ApplicationRecord
  has_one_attached :video # The video attachment is fine and can be retrieved and viewed

  def get_preview
    if video.attached? and video.previewable? # => true
       img_preview = video.preview(resize: "800x1400").processed # Returns an active storage instance with the file type mp4 instead of the expected png thumbnail
       return img_preview.service_url # Fails with exception (see next snippet)
    end
  end

这是我尝试检索预览的url时抛出的异常:

MiniMagick::Error: `identify -format %[orientation] /tmp/activeStorage20191128-4-1t9vihl.png[0]` failed with error:
2019-11-28T17:02:42.618871+00:00 app[worker.1]: identify-im6.q16: improper image header `/tmp/activeStorage20191128-4-1t9vihl.png' @ 

以前有人遇到过吗? active Storage预览API的文档实际上不存在,因此我不确定从哪里开始。

diegod3433 回答:活动存储:无法创建视频附件的图像预览

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2993043.html

大家都在问