@POST
@Path("download")
@Consumes(MediaType.APPLICATION_JSON)
public Response downloadData(@PathParam("jobId") JobId jobId)
throws IOException, UserNotFoundException, JobResourceNotFoundException {
final DownloadDataResponse response;
try {
response = supportService.downloadSupportRequest(context.getUserPrincipal().getName(), jobId);
} catch (JobNotFoundException e) {
throw JobResourceNotFoundException.fromJobNotFoundException(e);
}
final StreamingOutput streamingOutput = new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
IOUtils.copyBytes(response.getInput(), output, 4096, true);
}
};
return Response.ok(streamingOutput, MediaType.APPLICATION_OCTET_STREAM)
.header("Content-Disposition", "attachment; filename=\"" + response.getFileName() + "\"").build();
}
SupportResource.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:dremio-oss
作者:
评论列表
文章目录