提交 d41433b0 authored 作者: liupengfei's avatar liupengfei

--no commit message

上级 0d2f075f
......@@ -26,6 +26,7 @@ import io.swagger.annotations.ApiOperation;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
......@@ -91,7 +92,10 @@ public class EpubController {
if(StringUtils.isNotBlank(f.getIsbn())){
String isbn = f.getIsbn().trim();
try {
String destUrl = "http://192.168.2.247/file/book/"+isbn+"/epub/"+isbn+".epub";
String destUrl = "http://192.168.0.209/file/book/"+isbn+"/epub/"+isbn+".epub";
if(!getRource(destUrl)){
destUrl = "http://192.168.0.209/file/book/"+isbn+"/Epub/"+isbn+".epub";
}
//String path = "E:\\epub\\"+s;
//testIO(destUrl,isbn+".epub",path);
HttpURLConnection httpUrl = (HttpURLConnection) new URL(destUrl).openConnection();
......@@ -180,6 +184,20 @@ public class EpubController {
System.out.println("info:"+url+" download success");
}
@ApiOperation(value = "判断网络给定地址图片是否存在")
@RequestMapping(value = "/is", method = RequestMethod.GET)
public boolean getRource(String source) {
try {
URL url = new URL(source);
URLConnection uc = url.openConnection();
InputStream in = uc.getInputStream();
if (source.equalsIgnoreCase(uc.getURL().toString()))
in.close();
return true;
} catch (Exception e) {
return false;
}
}
......
......@@ -127,6 +127,9 @@ public class EpubUtil {
}else{
Resources ress = book.getResources();
res = ress.getById("cover");
if(res == null){
res = ress.getById("Cover");
}
return res;
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论