Return a file using Java Jersey

前端 未结 4 1108
孤城傲影
孤城傲影 2020-12-28 16:07

I am using the Java Jersey to implement a REST service. One thing my service should provide is a file download option. These files are quite big and are constructed from dat

4条回答
  •  遥遥无期
    2020-12-28 16:53

    How about

    File fileToSend = getFile();
    return Response.ok(fileToSend, "application/zip").build();
    

    The media type can be set to match the file being sent.

    This looks pretty straight forward but more importantly, do java experts reading this see a performance problem with the solution?

提交回复
热议问题