Commits

Anonymous committed 04c325f

Buffer input before reading zip file

Comments (0)

Files changed (1)

chempound-webapp/src/main/java/net/chempound/webapp/sword/impl/DepositRequestFactory.java

 
     private void processZipDeposit(final Deposit deposit, final DepositRequest depositRequest) throws SwordServerException {
         LOG.info("Processing zip deposit payload");
-        final ZipInputStream in = new ZipInputStream(deposit.getInputStream());
         try {
+            final ZipInputStream in = new ZipInputStream(getBufferedInput(deposit));
             for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in.getNextEntry()) {
                 final String filename = entry.getName();
                 final byte[] bytes = IOUtils.toByteArray(in);
         }
     }
 
-
+    private ByteArrayInputStream getBufferedInput(final Deposit deposit) throws IOException, SwordServerException {
+        final byte[] buffer = IOUtils.toByteArray(deposit.getInputStream());
+        return new ByteArrayInputStream(buffer);
+    }
 }