|
@@ -16,10 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.io.ByteArrayInputStream;
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.io.OutputStream;
|
|
|
|
|
|
+import java.io.*;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
import java.util.Base64;
|
|
import java.util.Base64;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -198,5 +195,45 @@ public class FileNodeController {
|
|
return Response.ok();
|
|
return Response.ok();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 打包下载生成的html页面
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/filenode/zip/{id}", method = RequestMethod.GET)
|
|
|
|
+ public void getFileZip(@PathVariable int id, final HttpServletResponse response) {
|
|
|
|
+
|
|
|
|
+ logger.info("Ready to get file byte on parentId:" + id);
|
|
|
|
+ byte[] data = null;
|
|
|
|
+ OutputStream outputStream = null;
|
|
|
|
+ try {
|
|
|
|
+ FileNode fileNode = fileManagerService.get(id);
|
|
|
|
+ data = fileManagerService.getFileZip(id);
|
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
|
+ response.setContentType("application/x-msdownload");
|
|
|
|
+ response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(fileNode.getName()+".zip", "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) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 访问html页面
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation("html页面")
|
|
|
|
+ @RequestMapping(value = "/enterprise/{id}/{name}", method = RequestMethod.GET)
|
|
|
|
+ public String getHtml(@PathVariable int id, @PathVariable String name) throws UnsupportedEncodingException {
|
|
|
|
+ return fileManagerService.getHtml(id, name);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|