From f167e8ea0a6b130e62558b26e0e86c63e6885a5d Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Fri, 9 Mar 2018 17:28:08 +0100 Subject: [PATCH] fix zip export --- .../main/java/com/sismics/docs/rest/resource/FileResource.java | 2 +- .../src/test/java/com/sismics/docs/rest/TestFileResource.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java index e283e584..84637018 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/FileResource.java @@ -584,7 +584,7 @@ public class FileResource extends BaseResource { // Files are encrypted by the creator of them User user = userDao.getById(file.getUserId()); try (InputStream decryptedStream = EncryptionUtil.decryptInputStream(fileInputStream, user.getPrivateKey())) { - ZipEntry zipEntry = new ZipEntry(file.getFullName(Integer.toString(index))); + ZipEntry zipEntry = new ZipEntry(index + "-" + file.getFullName(Integer.toString(index))); zipOutputStream.putNextEntry(zipEntry); ByteStreams.copy(decryptedStream, zipOutputStream); zipOutputStream.closeEntry(); diff --git a/docs-web/src/test/java/com/sismics/docs/rest/TestFileResource.java b/docs-web/src/test/java/com/sismics/docs/rest/TestFileResource.java index 0a5102fe..7939e044 100644 --- a/docs-web/src/test/java/com/sismics/docs/rest/TestFileResource.java +++ b/docs-web/src/test/java/com/sismics/docs/rest/TestFileResource.java @@ -161,6 +161,7 @@ public class TestFileResource extends BaseJerseyTest { .request() .cookie(TokenBasedSecurityFilter.COOKIE_NAME, file1Token) .get(); + Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus())); is = (InputStream) response.getEntity(); fileBytes = ByteStreams.toByteArray(is); Assert.assertEquals(MimeType.APPLICATION_ZIP, MimeTypeUtil.guessMimeType(fileBytes, null));