1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-16 03:06:22 +00:00

Download all files from a document as ZIP

This commit is contained in:
jendib
2014-02-23 14:09:41 +01:00
parent ae566018d6
commit 34e3ac5478
6 changed files with 121 additions and 3 deletions

View File

@@ -160,6 +160,16 @@ public class TestFileResource extends BaseJerseyTest {
Assert.assertEquals(file2Id, files.getJSONObject(0).getString("id"));
Assert.assertEquals(file1Id, files.getJSONObject(1).getString("id"));
// Get a ZIP from all files
fileResource = resource().path("/file/zip");
fileResource.addFilter(new CookieAuthenticationFilter(file1AuthenticationToken));
getParams = new MultivaluedMapImpl();
getParams.putSingle("id", document1Id);
response = fileResource.queryParams(getParams).get(ClientResponse.class);
is = response.getEntityInputStream();
fileBytes = ByteStreams.toByteArray(is);
Assert.assertEquals(MimeType.APPLICATION_ZIP, MimeTypeUtil.guessMimeType(fileBytes));
// Deletes a file
fileResource = resource().path("/file/" + file1Id);
fileResource.addFilter(new CookieAuthenticationFilter(file1AuthenticationToken));