From caf45613cfd64d9bfabcc0a93073a1c9f97577df Mon Sep 17 00:00:00 2001 From: vone Date: Mon, 25 Feb 2019 21:23:39 +0800 Subject: [PATCH] =?UTF-8?q?V1.3=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++ .../cn/szvone/img/service/VoneService.java | 27 ++++++++++++------- src/main/java/cn/szvone/img/util/SinaApi.java | 24 +++++++++++++---- src/main/webapp/index.html | 2 +- src/main/webapp/setting.html | 4 +-- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4909b63..67b85b2 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,10 @@ + 因本系统为无数据库模式,所以在war包的同级目录会生成一个vone.txt来保存系统配置,请您不要删除该文件,否则会导致配置丢失,系统会恢复默认配置! ## 更新记录 + + v1.3(2019.02.25) + + 很抱歉搜狗图床已经失效,无法使用外链,更新去除搜狗图床 + + 新浪图床上传程序更新,修复新浪图床上传提示服务器繁忙的BUG + + v1.2(2018.10.28) + 添加新浪图床支持 diff --git a/src/main/java/cn/szvone/img/service/VoneService.java b/src/main/java/cn/szvone/img/service/VoneService.java index 531fecb..15774ef 100644 --- a/src/main/java/cn/szvone/img/service/VoneService.java +++ b/src/main/java/cn/szvone/img/service/VoneService.java @@ -31,12 +31,13 @@ public ApiRes doUpload(String key, String imgBase64){ if (voneConfig.getType() == 1){ - String res = SougouApi.uploadImg(imgBase64); - if (res.indexOf("http")>=0){ - return ApiResultUtil.success(res); - }else{ - return ApiResultUtil.error("上传失败"); - } + return ApiResultUtil.error("搜狗图床已停止服务"); +// String res = SougouApi.uploadImg(imgBase64); +// if (res.indexOf("http")>=0){ +// return ApiResultUtil.success(res); +// }else{ +// return ApiResultUtil.error("上传失败"); +// } }else if (voneConfig.getType() == 2){ String ck = voneConfig.getSinaCookie(); long lastTime = 0; @@ -48,9 +49,11 @@ public ApiRes doUpload(String key, String imgBase64){ if (ck.equals("") || lastTime+10800000=0){ return ApiResultUtil.success(res); }else{ - return ApiResultUtil.error("上传失败"); + if (res.equals("-1")){ + voneConfig.setSinaCookie(""); + save(voneConfig); + return ApiResultUtil.error("新浪账号密码有误"); + }else { + return ApiResultUtil.error("服务器繁忙,错误代码:"+res); + } } } @@ -139,7 +148,7 @@ private VoneConfig getVoneConfig(){ try { voneConfig.setType(Integer.valueOf(VoneUtil.getSubString(myIni,"Type=[","]"))); }catch (Exception e){ - voneConfig.setType(1); + voneConfig.setType(2); } voneConfig.setSinaUpdateTime(VoneUtil.getSubString(myIni,"SinaUpdateTime=[","]")); }else{ @@ -148,7 +157,7 @@ private VoneConfig getVoneConfig(){ voneConfig.setSinaPass(""); voneConfig.setSinaCookie(""); voneConfig.setKey("123456"); - voneConfig.setType(1); + voneConfig.setType(2); voneConfig.setSinaUpdateTime(""); save(voneConfig); } diff --git a/src/main/java/cn/szvone/img/util/SinaApi.java b/src/main/java/cn/szvone/img/util/SinaApi.java index f50f410..9fd4183 100644 --- a/src/main/java/cn/szvone/img/util/SinaApi.java +++ b/src/main/java/cn/szvone/img/util/SinaApi.java @@ -17,7 +17,7 @@ public class SinaApi { public static String uploadImg(String imgBase64,String ck) { - String url = "http://picupload.service.weibo.com/interface/pic_upload.php?mime=image%2Fjpeg&data=base64&url=0&markpos=1&logo=&nick=0&marks=1&app=miniblog"; + String url = "http://picupload.weibo.com/interface/pic_upload.php?cb=https%3A%2F%2Fweibo.com%2Faj%2Fstatic%2Fupimgback.html%3F_wv%3D5%26callback%3DSTK_ijax_1551096206285100&mime=image%2Fjpeg&data=base64&url=weibo.com%2Fu%2F5734329255&markpos=1&logo=1&nick=&marks=0&app=miniblog&s=rdxt&pri=0&file_source=2"; @@ -28,6 +28,9 @@ public static String uploadImg(String imgBase64,String ck) { InputStream inputStream = null; //尝试发送请求 try { + + //ck="SUB=_2A25xd6e5DeRhGeNJ6FYS8ifOzjmIHXVSBJ5xrDV8PUNbmtAKLXnHkW9NS8PUgB08tOVmchSobLjjnfy2-EM-svCC;"; + u = new URL(url); con = (HttpURLConnection) u.openConnection(); con.setRequestMethod("POST"); @@ -46,6 +49,7 @@ public static String uploadImg(String imgBase64,String ck) { //读取返回内容 inputStream = con.getInputStream(); + //https://weibo.com/aj/static/upimgback.html?_wv=5&callback=STK_ijax_1551096206285100&ret=1&pid=006g4EZxgy1g0iz2blozoj30u01aogo9 InputStreamReader isr = new InputStreamReader(inputStream); BufferedReader bufr = new BufferedReader(isr); @@ -57,13 +61,23 @@ public static String uploadImg(String imgBase64,String ck) { ret+=str; } - ret = VoneUtil.getSubString(ret,"\"name\":\"pic_1\",\"pid\":\"","\"}"); + System.out.println(con.getHeaderField("location")); - if (!ret.equals("")){ - ret = "http://wx1.sinaimg.cn/large/"+ret+".jpg"; + String retCode = VoneUtil.getSubString(con.getHeaderField("location")+"&","&ret=","&"); + if (retCode.equals("1")){ + ret = VoneUtil.getSubString(con.getHeaderField("location")+"&","&pid=","&"); + + if (!ret.equals("")){ + ret = "http://wx1.sinaimg.cn/large/"+ret+".jpg"; + } + }else { + ret = retCode; } + + + } catch (Exception e) { e.printStackTrace(); } finally { @@ -110,7 +124,7 @@ public static String login(String user,String pass){ while ((str = bufr.readLine()) != null) { ret+=str; } - + System.out.println(ret); //获取cookie Map> map=con.getHeaderFields(); Set set=map.keySet(); diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index a3c7235..296281e 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -43,7 +43,7 @@

超简图床

轻量级图床程序(JAVA版)

- 本套图床程序提供搜狗CDN存储(无需配置)、新浪CDN存储(需要配置新浪账号【推荐】)、本地存储(需占用服务器空间)三种模式可供切换选择,对外提供Api接口实现图片上传,一键搭建,简单调用!

+ 本套图床程序提供搜狗CDN存储(无需配置【已经失效】)、新浪CDN存储(需要配置新浪账号【推荐】)、本地存储(需占用服务器空间)三种模式可供切换选择,对外提供Api接口实现图片上传,一键搭建,简单调用!

获取程序

diff --git a/src/main/webapp/setting.html b/src/main/webapp/setting.html index 0dfa5e9..8a8f28c 100644 --- a/src/main/webapp/setting.html +++ b/src/main/webapp/setting.html @@ -50,9 +50,9 @@

系统配置

运行模式