@GET @Path("/downloadFile") ActionStatus downloadFile(@QueryParam("file") String file);
And as well as thence inwards the implementation nosotros have:
populace void downloadFile(String filePath) throws BusinessApiException { HttpServletResponse reply = // encounter https://ngeblognow.blogspot.com//search?q=how-to-access-httpservletrequest-and File file = novel File(getProviderRootDir() + File.separator + filePath); if (!file.exists()) { // grip exception } campaign { FileInputStream fis = novel FileInputStream(file); response.setContentType(Files.probeContentType(file.toPath())); response.setContentLength((int) file.length()); response.addHeader("Content-disposition", "attachment;filename=\"" + file.getName() + "\""); IOUtils.copy(fis, response.getOutputStream()); response.flushBuffer(); } select direct maintain of (IOException e) { // grip exception } }
*Note: IOUtils is from apache commons.
0 komentar:
Please comment if there are any that need to be asked.