문제

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