mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 23:27:57 +01:00
fix zip export
This commit is contained in:
parent
de703531f6
commit
f167e8ea0a
@ -584,7 +584,7 @@ public class FileResource extends BaseResource {
|
|||||||
// Files are encrypted by the creator of them
|
// Files are encrypted by the creator of them
|
||||||
User user = userDao.getById(file.getUserId());
|
User user = userDao.getById(file.getUserId());
|
||||||
try (InputStream decryptedStream = EncryptionUtil.decryptInputStream(fileInputStream, user.getPrivateKey())) {
|
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);
|
zipOutputStream.putNextEntry(zipEntry);
|
||||||
ByteStreams.copy(decryptedStream, zipOutputStream);
|
ByteStreams.copy(decryptedStream, zipOutputStream);
|
||||||
zipOutputStream.closeEntry();
|
zipOutputStream.closeEntry();
|
||||||
|
@ -161,6 +161,7 @@ public class TestFileResource extends BaseJerseyTest {
|
|||||||
.request()
|
.request()
|
||||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, file1Token)
|
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, file1Token)
|
||||||
.get();
|
.get();
|
||||||
|
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
||||||
is = (InputStream) response.getEntity();
|
is = (InputStream) response.getEntity();
|
||||||
fileBytes = ByteStreams.toByteArray(is);
|
fileBytes = ByteStreams.toByteArray(is);
|
||||||
Assert.assertEquals(MimeType.APPLICATION_ZIP, MimeTypeUtil.guessMimeType(fileBytes, null));
|
Assert.assertEquals(MimeType.APPLICATION_ZIP, MimeTypeUtil.guessMimeType(fileBytes, null));
|
||||||
|
Loading…
Reference in New Issue
Block a user