我有一个scala控制器,它在响应的输出流中放入一个zip文件。如果我使用直接链接,文件下载没有问题。但是当我通过swagger-ui执行请求时,文件二进制内容会显示在UI上并且加载不会启动。
@RequestMapping(value = Array("/get-response"), method = Array(RequestMethod.GET), produces = Array(MediaType.APPLICATION_OCTET_STREAM_VALUE))
@ApiOperation(value = "api-response", notes = "Receive Response Request.")
def getResponse(response: HttpServletResponse): Unit = {
response.setContentType("application/zip")
response.addHeader("Content-Disposition", "attachment; filename=\"Response.zip\"");
//writing to response.getOutputStream()
response.flushBuffer()
}
如何删除二进制正文并下载文件?感谢