Question

The following code downloads a zip file. Am I doing something wrong here? The zip file downloads but can't unarchive.

ByteArrayOutputStream baos = getByteArrOutputStream();
        ZipOutputStream zos = new ZipOutputStream(baos);
        zos.putNextEntry(new ZipEntry("report.txt"));
        zos.write(baos.toByteArray());
        zos.closeEntry();
        zos.close();

        this.setBuffer(baos.toByteArray());
        this.setContentType("application/zip");
Was it helpful?

Solution

Try

this.setContentType("application/octet-stream")

instead of

this.setContentType("application/zip")

it should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top