Commit 86bb6f0b802c6596a5fb3ead8548e55309175a45
1 parent
30fbfb61
优化上传文件的类型识别,增加基于 filename 的读取
Showing
1 changed file
with
1 additions
and
1 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java
| @@ -39,7 +39,7 @@ public class FileServiceImpl implements FileService { | @@ -39,7 +39,7 @@ public class FileServiceImpl implements FileService { | ||
| 39 | @Override | 39 | @Override |
| 40 | public String createFile(String path, byte[] content) throws Exception { | 40 | public String createFile(String path, byte[] content) throws Exception { |
| 41 | // 计算默认的 path 名 | 41 | // 计算默认的 path 名 |
| 42 | - String type = FileTypeUtil.getType(new ByteArrayInputStream(content)); | 42 | + String type = FileTypeUtil.getType(new ByteArrayInputStream(content), path); |
| 43 | if (StrUtil.isEmpty(path)) { | 43 | if (StrUtil.isEmpty(path)) { |
| 44 | path = DigestUtil.md5Hex(content) + '.' + type; | 44 | path = DigestUtil.md5Hex(content) + '.' + type; |
| 45 | } | 45 | } |