|
@@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
import org.springframework.web.servlet.HandlerMapping;
|
|
|
-import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -222,14 +221,42 @@ public class CommonController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param modelAndView
|
|
|
- * @return
|
|
|
- * @功能:pdf预览Iframe
|
|
|
+ * @功能:pdf预览
|
|
|
*/
|
|
|
- @RequestMapping("/pdf/pdfPreviewIframe")
|
|
|
- public ModelAndView pdfPreviewIframe(ModelAndView modelAndView) {
|
|
|
- modelAndView.setViewName("pdfPreviewIframe");
|
|
|
- return modelAndView;
|
|
|
+ @RequestMapping("/pdf/preview/**")
|
|
|
+ public void pdfPreviewIframe(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ String imgPath = extractPathFromPattern(request);
|
|
|
+ // 其余处理略
|
|
|
+ InputStream inputStream = null;
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ inputStream = MinioUtil.getMinioFile(imgPath);
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
+ byte[] buf = new byte[1024];
|
|
|
+ int len;
|
|
|
+ while ((len = inputStream.read(buf)) > 0) {
|
|
|
+ outputStream.write(buf, 0, len);
|
|
|
+ }
|
|
|
+ response.flushBuffer();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("预览文件失败" + e.getMessage());
|
|
|
+ } finally {
|
|
|
+ if (inputStream != null) {
|
|
|
+ try {
|
|
|
+ inputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.info("imgPath:{}", imgPath);
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|