diff --git a/src/main/java/fi/solita/clamav/ClamAVProxy.java b/src/main/java/fi/solita/clamav/ClamAVProxy.java index 2b24411..124a1fb 100644 --- a/src/main/java/fi/solita/clamav/ClamAVProxy.java +++ b/src/main/java/fi/solita/clamav/ClamAVProxy.java @@ -43,4 +43,16 @@ public String ping() throws IOException { return "Everything ok : " + ClamAVClient.isCleanReply(r) + "\n"; } else throw new IllegalArgumentException("empty file"); } + + /** + * @return Clamd scan reply + */ + @RequestMapping(value="/scanReply", method=RequestMethod.POST) + public @ResponseBody String handleFileUploadReply(@RequestParam("name") String name, + @RequestParam("file") MultipartFile file) throws IOException{ + if (!file.isEmpty()) { + ClamAVClient a = new ClamAVClient(hostname, port, timeout); + return new String(a.scan(file.getInputStream())); + } else throw new IllegalArgumentException("empty file"); + } } diff --git a/src/test/java/fi/solita/clamav/PingTest.java b/src/test/java/fi/solita/clamav/PingTest.java deleted file mode 100644 index 99a902f..0000000 --- a/src/test/java/fi/solita/clamav/PingTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package fi.solita.clamav; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.springframework.web.client.RestTemplate; - -/** - * These tests assume clamav-rest Docker container is running and responding locally. - */ -public class PingTest { - - @Test - public void testPing() { - RestTemplate t = new RestTemplate(); - String s = t.getForObject("http://localhost:8080", String.class); - assertEquals(s, "Clamd responding: true\n"); - } -}