Why is MIME media type application/zip not found?

Fariba picture Fariba · Sep 14, 2015 · Viewed 11.4k times · Source

I need to return zip file in my rest Api but i receive MIME media type application/zip was not found.

@Produces({ "application/zip" })
    public Response convertFile(){
    .
    .
    .
    return Response.ok(result, "application/zip").build();
} 

Answer

Oleksandr Loushkin picture Oleksandr Loushkin · Sep 14, 2015

Try this:

@Produces("application/zip")

 return Response
            .ok(FileUtils.readFileToByteArray(resultFile))
            .type("application/zip")
            .header("Content-Disposition", "attachment; filename=\"yourfile.zip\"")
            .build();