mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-14 13:13:47 +08:00
修复流的方法错误 ,修复跨域脚本缺少BASE64 (#423)
* 修复office下载方法中 错误 * 更新OFD解析效果,修复禁止trace请求无效问题,其他压缩包修复 * 修复压缩包 缓存BUG * 限制某些特殊文件上传 * 修复OFFICE文件密码检查关闭流 上传文件关闭流 检查PDF文件是否存在 * 特殊符号的支持 Co-authored-by: gaoxiongzaq <admin@cxcp.com>
This commit is contained in:
@@ -31,7 +31,7 @@ import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author yudian-it
|
||||
* @date 2017/12/1
|
||||
* 2017/12/1
|
||||
*/
|
||||
@RestController
|
||||
public class FileController {
|
||||
@@ -64,6 +64,15 @@ public class FileController {
|
||||
if (pos != -1) {
|
||||
fileName = fileName.substring(pos + 1);
|
||||
}
|
||||
String fileType= "";
|
||||
int i = fileName.lastIndexOf('.');
|
||||
if (i > 0) {
|
||||
fileType= fileName.substring(i+1);
|
||||
fileType= fileType.toLowerCase();
|
||||
}
|
||||
if (fileType.length() == 0 || fileType.equals("dll") || fileType.equals("exe") || fileType.equals("msi") ){
|
||||
return ReturnResponse.failure(fileName+"不允许上传的文件");
|
||||
}
|
||||
// 判断是否存在同名文件
|
||||
if (existsFile(fileName)) {
|
||||
return ReturnResponse.failure("存在同名文件,请先删除原有文件再次上传");
|
||||
@@ -75,6 +84,8 @@ public class FileController {
|
||||
logger.info("上传文件:{}", fileDir + demoPath + fileName);
|
||||
try (InputStream in = file.getInputStream(); OutputStream out = Files.newOutputStream(Paths.get(fileDir + demoPath + fileName))) {
|
||||
StreamUtils.copy(in, out);
|
||||
in.close();
|
||||
out.close();
|
||||
return ReturnResponse.success(null);
|
||||
} catch (IOException e) {
|
||||
logger.error("文件上传失败", e);
|
||||
|
||||
Reference in New Issue
Block a user