🐛 fixed
This commit is contained in:
parent
644ba31d1c
commit
12ccb9b7d0
3
.gitignore
vendored
3
.gitignore
vendored
@ -35,4 +35,5 @@ build/
|
||||
index
|
||||
userDic
|
||||
|
||||
/src/main/resources/application.yml
|
||||
|
||||
*.yml
|
||||
|
10
pom.xml
10
pom.xml
@ -296,16 +296,6 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<!--打包过程中跳过测试-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<configuration>
|
||||
<!--true跳过测试-->
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user