word,excel预览

This commit is contained in:
zhn
2022-06-09 18:01:19 +08:00
parent 3de6b0f4a3
commit 5978500d01
@@ -293,20 +293,17 @@ public class CommonController {
InputStream inputStream = null;
OutputStream outputStream = null;
try {
String fileName = "";
//本地下载
String filePath = ossFile.getUrl();
File file = new File(filePath);
if(!file.exists()){
if(!CosBootUtil.doesObjectExist(filePath)){
response.setStatus(404);
throw new RuntimeException("文件不存在..");
}
// 文件名称
fileName = file.getName();
inputStream = new BufferedInputStream(new FileInputStream(filePath));
response.setContentType("application/force-download");// 设置强制下载不打开
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
inputStream = new BufferedInputStream(new FileInputStream(filePath));
inputStream = CosBootUtil.download(filePath);
outputStream = response.getOutputStream();
byte[] buf = new byte[1024];
int len;