fix zip export

This commit is contained in:
Benjamin Gamard 2018-03-09 17:28:08 +01:00
parent de703531f6
commit f167e8ea0a
2 changed files with 2 additions and 1 deletions

View File

@ -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();

View File

@ -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));