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");
有帮助吗?

解决方案

Try

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

instead of

this.setContentType("application/zip")

it should work.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top