diff --git a/.gitignore b/.gitignore index 6504885..948d99e 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ build/ index userDic -/src/main/resources/application.yml \ No newline at end of file + +*.yml diff --git a/pom.xml b/pom.xml index 6596ea2..2d18bc8 100644 --- a/pom.xml +++ b/pom.xml @@ -296,16 +296,6 @@ - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M5 - - - true - - org.springframework.boot spring-boot-maven-plugin diff --git a/src/main/java/com/rymcu/forest/web/api/common/UploadController.java b/src/main/java/com/rymcu/forest/web/api/common/UploadController.java index 210e1a1..f6b8160 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/UploadController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/UploadController.java @@ -251,6 +251,17 @@ public class UploadController { TokenUser tokenUser = getTokenUser(request); String url = linkToImageUrlDTO.getUrl(); + Map data = new HashMap(2); + + if (StringUtils.isBlank(url)) { + data.put("message", "文件为空!"); + return GlobalResultGenerator.genSuccessResult(data); + } + if (url.contains(Utils.getProperty("resource.file-path"))) { + data.put("originalURL", url); + data.put("url", url); + return GlobalResultGenerator.genSuccessResult(data); + } URL link = new URL(url); HttpURLConnection conn = (HttpURLConnection) link.openConnection(); //设置超时间为3秒 @@ -258,7 +269,6 @@ public class UploadController { //防止屏蔽程序抓取而返回403错误 conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"); conn.setRequestProperty("referer", ""); - Map data = new HashMap(2); //得到输入流 try (InputStream inputStream = conn.getInputStream()) { //获取自己数组 @@ -308,8 +318,6 @@ public class UploadController { data.put("message", "上传失败"); return GlobalResultGenerator.genSuccessResult(data); } - - } }