1 year ago

#188570

test-img

Aadhi Vive

Shrine - How to prevent Shrine from auto uploading files prior to validation - Ruby Upload Gem

This question is for anyone who has experience with the Ruby Gem Shrine for File Uploads.

I am trying to scan file uploads for viruses using ClamAV. The scan works well however the file is already auto uploaded to cloud storage by Shrine prior to validation.

  • Is there a hook/callback in Shrine we can use to run the scan prior to file is uploaded?
  • Is there are an alternative approach?

Here is the code at the moment.

Attacher.validate do
    if file
      tmp_file = file.download
      # raise Services::Clamav::Client::FileContainVirus
      errors << "virus file" if Services::Clamav::Client.virus?(tmp_file.path)
    end
 end

Any thoughts/answers will help. Thank you.

ruby-on-rails

ruby

file-upload

shrine

antivirus-integration

0 Answers

Your Answer

Accepted video resources