1

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.

Aadhi Vive
  • 575
  • 1
  • 5
  • 17

0 Answers0