0

How can I integrate clamav with django rest framework? I am trying to scan uploaded files via drf with clamav? I installed clamav from https://www.clamav.net/

here is my code

...
file = self.request.FILES.get('file')
# check a file for viruses
if file:
   print("checking file for viruses")
   from tempfile import mkstemp
   from py_clamav import ClamAvScanner
   import os
   tmpfile = mkstemp()[1]
   f = open(tmpfile, 'wb')
   f.write(file.read())
   f.close()

   with ClamAvScanner() as scanner:
       # scan file by path
       infected, virname = scanner.scan_file(tmpfile)

       os.unlink(tmpfile)
       if infected:
           return Response({'message':"virus was detected in your file"},status=status.HTTP_400_BAD_REQUEST)
...

I am getting the error:

raise FileNotFoundError('Not found libclamav')
FileNotFoundError: Not found libclamav

Why are my getting this error? Is there a better library I can do this with?

user14665310
  • 524
  • 4
  • 13

0 Answers0