mirror of
https://github.com/dataease/dataease.git
synced 2025-02-24 19:42:56 +08:00
refactor: 优化图片上传错误提示
This commit is contained in:
parent
3419beb6f3
commit
2bdedf7fe7
@ -118,7 +118,7 @@ public class StaticResourceServer implements StaticResourceApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidSVG(MultipartFile file) {
|
private static boolean isValidSVG(MultipartFile file){
|
||||||
if (file == null || file.isEmpty()) {
|
if (file == null || file.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -143,9 +143,14 @@ public class StaticResourceServer implements StaticResourceApi {
|
|||||||
}
|
}
|
||||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||||
// 如果出现任何解析错误,说明该文件不是合法的SVG
|
// 如果出现任何解析错误,说明该文件不是合法的SVG
|
||||||
return false;
|
if(e.getMessage() != null && e.getMessage().indexOf("DOCTYPE")>-1){
|
||||||
|
DEException.throwException("svg 内容禁止使用 DOCTYPE");
|
||||||
|
}else {
|
||||||
|
DEException.throwException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public static FileType getFileType(InputStream is) throws IOException {
|
public static FileType getFileType(InputStream is) throws IOException {
|
||||||
byte[] src = new byte[28];
|
byte[] src = new byte[28];
|
||||||
is.read(src, 0, 28);
|
is.read(src, 0, 28);
|
||||||
|
Loading…
Reference in New Issue
Block a user