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();
}
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();
}
Try this:
@Produces("application/zip")
return Response
.ok(FileUtils.readFileToByteArray(resultFile))
.type("application/zip")
.header("Content-Disposition", "attachment; filename=\"yourfile.zip\"")
.build();
Use MediaType#MULTIPART_FORM_DATA_TYPE
.
read: http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/MediaType.html#MULTIPART_FORM_DATA
You can simply do this too.
@Produces("application/zip")
public File getAZipFile(){
//your controller code which returns a file
return file;
}
Note: Accept headers must be application/zip
© 2022 - 2024 — McMap. All rights reserved.
MessageBodyWriter
forapplication/zip
and the Java type or just useapplication/octect-stream
– Palikar