提交 5615135d authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 bbe04682
...@@ -42,6 +42,7 @@ import org.springframework.http.HttpStatus; ...@@ -42,6 +42,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -622,4 +623,29 @@ public class FileController { ...@@ -622,4 +623,29 @@ public class FileController {
return CallBack.success(fileInfo); return CallBack.success(fileInfo);
} }
@PostMapping("viewerit.html")
public void viewerit(HttpServletRequest request, HttpServletResponse response,String oid) throws Exception {
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("application/pdf;charset=UTF-8");
String filePath = null;
if (StringUtils.isNotBlank(oid)) {
FileInfo entity = new FileInfo();
entity.setFileName(oid);
entity = service.selectOne(entity);
if (entity.getId() == null) {
throw new BaseException(1,"没有找到该文件!");
}
filePath = entity.getPath()+"/"+entity.getFileName()+entity.getSuffixName();
}
File file = new File(rootPath+filePath);
FileInputStream in = new FileInputStream(file);
BufferedInputStream input = new BufferedInputStream(in);
byte buffBytes[] = new byte[1024];
int read = 0;
while ((read = input.read(buffBytes)) != -1) {
response.getOutputStream().write(buffBytes, 0, read);
}
response.getOutputStream().flush();
response.getOutputStream().close();
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论