!321 解决文件输入流为可能为空的问题

Merge pull request !321 from maochd/master
pull/322/head
若依 2 years ago committed by Gitee
commit 5fcec99e6c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -126,15 +126,8 @@ public class FileUtils
{ {
return false; return false;
} }
// 判断是否在允许下载的文件规则内
// 检查允许下载的文件规则 return ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource));
if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
{
return true;
}
// 不在允许下载的文件规则
return false;
} }
/** /**

@ -1,6 +1,8 @@
package com.ruoyi.file.service; package com.ruoyi.file.service;
import java.io.InputStream; import java.io.InputStream;
import com.alibaba.nacos.common.utils.IoUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -39,7 +41,7 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
InputStream inputStream = file.getInputStream(); InputStream inputStream = file.getInputStream();
StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(), StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
FileTypeUtils.getExtension(file), null); FileTypeUtils.getExtension(file), null);
inputStream.close(); IoUtils.closeQuietly(inputStream);
return domain + "/" + storePath.getFullPath(); return domain + "/" + storePath.getFullPath();
} }
} }

Loading…
Cancel
Save