Reputation: 31
As part of our requirements, we need to upload some files to database. Is there any way we can do virus scan on those files before saving them to database.
Upvotes: 3
Views: 1899
Reputation: 92772
Your server is probably not at risk from viruses; however, you probably want to check the files anyway - it is entirely possible for a Windows-using client to upload an infected file, and another Windows-using client to download it and infect themselves. By checking for malware at the server, you could stop it from spreading - so the net result is positive, even if the malware doesn't attack your server directly.
If your server runs something UN*X-ish (Linux, BSD, ...), you may want to look at ClamAV, and its Java bindings, clamavj: these provide various scan capabilities (e.g. on-demand or automatic in a given location), even for different-platform malware (e.g. you can check for Windows viruses, even though your server runs Linux).
Upvotes: 1
Reputation: 45263
I personally use Free AVG as my anti-virus program on my Windows machine. It comes with a command-line scanning utility which allows you to scan files manually. This could easily be executed from Java code.
I am sure some of the other anti-virus applications also come with command-line versions of their scanners. Any of these would be easily executed from Java code.
If you are on a UNIX machine, you may want to question this requirement of virus scanning since UNIX viruses are very rare and the effective ones are not easily detectable by anti-virus software. The value of such a feature may be non-existent.
Upvotes: 2