word,excel预览
This commit is contained in:
+2
-5
@@ -293,20 +293,17 @@ public class CommonController {
|
|||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
OutputStream outputStream = null;
|
OutputStream outputStream = null;
|
||||||
try {
|
try {
|
||||||
String fileName = "";
|
|
||||||
//本地下载
|
//本地下载
|
||||||
String filePath = ossFile.getUrl();
|
String filePath = ossFile.getUrl();
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
if(!file.exists()){
|
if(!CosBootUtil.doesObjectExist(filePath)){
|
||||||
response.setStatus(404);
|
response.setStatus(404);
|
||||||
throw new RuntimeException("文件不存在..");
|
throw new RuntimeException("文件不存在..");
|
||||||
}
|
}
|
||||||
// 文件名称
|
// 文件名称
|
||||||
fileName = file.getName();
|
|
||||||
inputStream = new BufferedInputStream(new FileInputStream(filePath));
|
|
||||||
response.setContentType("application/force-download");// 设置强制下载不打开
|
response.setContentType("application/force-download");// 设置强制下载不打开
|
||||||
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
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();
|
outputStream = response.getOutputStream();
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
int len;
|
int len;
|
||||||
|
|||||||
Reference in New Issue
Block a user