|
@@ -149,6 +149,31 @@ public class FileNodeController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping(value = "/filenode/{id}/type/{xx}", method = RequestMethod.GET)
|
|
|
+ public void getFileTo(@PathVariable int id, @PathVariable String xx, final HttpServletResponse response) {
|
|
|
+ logger.info("Ready to get file byte on parentId:" + id);
|
|
|
+ byte[] data = null;
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ data = fileManagerService.getByte(id);
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ response.setContentType("application/x-msdownload");
|
|
|
+ response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(xx, "UTF-8"));
|
|
|
+ OutputStream outputSream = response.getOutputStream();
|
|
|
+ outputSream.write(data);
|
|
|
+ outputSream.flush();
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BadRequestException("Fail to write stream", Constant.RET_DOCUMENT_ERROR, e);
|
|
|
+ } finally {
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@RequestMapping(value = "/filenode/{id}/render", method = RequestMethod.GET)
|
|
|
public Response renderDocument( @PathVariable int id , final HttpServletResponse response) {
|