download - How do i return a response as excel file using dropwizard? -
i using dropwizard rest api development, returns json response. have come across requirement have return excel file on call of 1 particular api. found out apache poi library use. how return excel file response . browser should show option download.
set content-type application/octet-stream
, add content-disposition
response header should it. content-disposition: attachment; filename="file.xsl"
. example
@path("/file") public class fileresource { @get @produces(mediatype.application_octet_stream) public response getfile() throws exception { inputstream = new fileinputstream("file.txt"); return response.ok(is) .header(httpheaders.content_disposition, "attachment; filename=\"file.txt\"") .build(); } }
other inputstream
, return file
, byte[]
, streamingoutput
, have options.
Comments
Post a Comment