Commit 1766e3332edaf5645da6a0d0ed23980fad8572f6
1 parent
db5020d0
fix: 修复文件路径上传错误
Showing
1 changed file
with
7 additions
and
4 deletions
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/common/ImageConverter.java
| @@ -35,12 +35,15 @@ public class ImageConverter implements Converter<String> { | @@ -35,12 +35,15 @@ public class ImageConverter implements Converter<String> { | ||
| 35 | @Override | 35 | @Override |
| 36 | public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, | 36 | public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, |
| 37 | GlobalConfiguration globalConfiguration) throws IOException { | 37 | GlobalConfiguration globalConfiguration) throws IOException { |
| 38 | - String path = RuoYiConfig.getProfile() + value.replace("/profile",""); | 38 | + String path = RuoYiConfig.getProfile() + value.replace("/profile", ""); |
| 39 | System.out.println(path); | 39 | System.out.println(path); |
| 40 | File file = new File(path + File.separator); | 40 | File file = new File(path + File.separator); |
| 41 | - if (!file.exists()){ | ||
| 42 | - return new CellData("没有图片"); | 41 | + if (file.exists()) { |
| 42 | + if (file.isDirectory() || !file.canRead()) { | ||
| 43 | + return new CellData("没有图片"); | ||
| 44 | + } | ||
| 45 | + return new CellData(FileUtils.readFileToByteArray(file)); | ||
| 43 | } | 46 | } |
| 44 | - return new CellData(FileUtils.readFileToByteArray(file)); | 47 | + return new CellData("没有图片"); |
| 45 | } | 48 | } |
| 46 | } | 49 | } |