Skip to content

Large temp file creation when a video is analysed #526

@brendon

Description

@brendon

Hi @markevans, I'm hoping you can help me figure out a plan to solve this thorny issue :)

I have a generic file store that uses plugin :imagemagick so that I can transform images if they're detected as such, but it's an open ended store, so users can upload any kind of file there. Unfortunately imagemagick chokes when you ask it to identify a mp4 file. A user uploaded a 200MB mp4 and imagemagick proceeded to use up 15GB of disk space and crash the machine.

I know there are ways to limit all of those side effects but I think the best thing would be to add a pre-check to ensure we're dealing only with real images before invoking identify. Imagemagick seems to be capable of processing video files but at great cost, so it's probably worth skipping in this case.

Initial thoughts were to run something like file --mime-type -b video.mp4 and check the type there, or perhaps there's a Ruby equivalent that's better suited and safer.

Would this be the best place for it?

app.add_analyser :image do |content|
begin
content.analyse(:image_properties)["format"] != "pdf"
rescue Shell::CommandFailed
false
end
end

And finally, is this just something I can override myself by adding something like this to my dragonfly configuration?

  analyser :image do |content|
    # Detection Override
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions