Skip to content

Commit

Permalink
https://github.com/sanluan/PublicCMS/issues/51
Browse files Browse the repository at this point in the history
  • Loading branch information
sanluan committed Feb 24, 2021
1 parent 276f2fb commit 0f4c487
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ public Map<String, Object> catchimage(@RequestAttribute SysSite site, @SessionAt
BufferedInputStream inputStream = new BufferedInputStream(entity.getContent());
FileType fileType = FileTypeDetector.detectFileType(inputStream);
String suffix = fileType.getCommonExtension();
if (CommonUtils.notEmpty(suffix)) {
if (null != fileType.getMimeType() && fileType.getMimeType().startsWith("image/")
&& CommonUtils.notEmpty(suffix)) {
String fileName = CmsFileUtils.getUploadFileName(suffix);
String filePath = siteComponent.getWebFilePath(site, fileName);
CmsFileUtils.copyInputStreamToFile(inputStream, filePath);
Expand All @@ -238,9 +239,13 @@ public Map<String, Object> catchimage(@RequestAttribute SysSite site, @SessionAt
}
EntityUtils.consume(entity);
}
Map<String, Object> map = getResultMap(true);
map.put("list", list);
return map;
if (list.isEmpty()) {
return getResultMap(false);
} else {
Map<String, Object> map = getResultMap(true);
map.put("list", list);
return map;
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
Expand Down

0 comments on commit 0f4c487

Please sign in to comment.