diff --git a/src/main/java/cn/hellohao/service/impl/COSImageupload.java b/src/main/java/cn/hellohao/service/impl/COSImageupload.java index 3a0d6db..768a58a 100644 --- a/src/main/java/cn/hellohao/service/impl/COSImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/COSImageupload.java @@ -47,14 +47,16 @@ public class COSImageupload { returnImage.setImgSize(entry.getValue().length()); returnImage.setCode("200"); } catch (CosServiceException serverException) { + returnImage.setCode("400"); serverException.printStackTrace(); } catch (CosClientException clientException) { + returnImage.setCode("400"); clientException.printStackTrace(); } } }catch(Exception e){ e.printStackTrace(); - returnImage.setCode("200"); + returnImage.setCode("500"); } return returnImage; } diff --git a/src/main/java/cn/hellohao/service/impl/ClientService.java b/src/main/java/cn/hellohao/service/impl/ClientService.java index 98de830..6e6cdea 100644 --- a/src/main/java/cn/hellohao/service/impl/ClientService.java +++ b/src/main/java/cn/hellohao/service/impl/ClientService.java @@ -126,7 +126,7 @@ public class ClientService { e.printStackTrace(); System.out.println("未获取到图片的MD5,成成UUID"); } - Msg fileMiME = TypeDict.FileMiME(file, uploadConfig.getSuffix()); + Msg fileMiME = TypeDict.FileMiME(file); if (!fileMiME.getCode().equals("200")) { //非图像文本 msg.setCode("4009"); diff --git a/src/main/java/cn/hellohao/service/impl/KODOImageupload.java b/src/main/java/cn/hellohao/service/impl/KODOImageupload.java index 08b855c..2d9f5c7 100644 --- a/src/main/java/cn/hellohao/service/impl/KODOImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/KODOImageupload.java @@ -53,7 +53,6 @@ public class KODOImageupload { try { for (Map.Entry entry : fileMap.entrySet()) { String ShortUID = SetText.getShortUuid(); - java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); file = entry.getValue(); try { Response response = uploadManager.put(file,username + "/" + ShortUID + "." + entry.getKey(),upToken); @@ -63,6 +62,7 @@ public class KODOImageupload { returnImage.setImgSize(entry.getValue().length()); returnImage.setCode("200"); } catch (QiniuException ex) { + returnImage.setCode("400"); Response r = ex.response; System.err.println(r.toString()); try { diff --git a/src/main/java/cn/hellohao/service/impl/OSSImageupload.java b/src/main/java/cn/hellohao/service/impl/OSSImageupload.java index ec13791..30c9a92 100644 --- a/src/main/java/cn/hellohao/service/impl/OSSImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/OSSImageupload.java @@ -1,6 +1,7 @@ package cn.hellohao.service.impl; import cn.hellohao.pojo.Keys; +import cn.hellohao.pojo.Msg; import cn.hellohao.pojo.ReturnImage; import cn.hellohao.utils.*; import com.aliyun.oss.OSS; @@ -27,6 +28,8 @@ public class OSSImageupload { String ShortUID = SetText.getShortUuid(); java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); file = entry.getValue(); + Msg fileMiME = TypeDict.FileMiME(file); + meta.setHeader("content-type", fileMiME.getData().toString()); System.out.println("待上传的图片:"+username + "/" + ShortUID + "." + entry.getKey()); ossClient.putObject(key.getBucketname(), username + "/" + ShortUID + "." + entry.getKey(),file); returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());//entry.getValue().getOriginalFilename() diff --git a/src/main/java/cn/hellohao/service/impl/UFileImageupload.java b/src/main/java/cn/hellohao/service/impl/UFileImageupload.java index 994f00b..13bdf2d 100644 --- a/src/main/java/cn/hellohao/service/impl/UFileImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/UFileImageupload.java @@ -1,6 +1,7 @@ package cn.hellohao.service.impl; import cn.hellohao.pojo.Keys; +import cn.hellohao.pojo.Msg; import cn.hellohao.pojo.ReturnImage; import cn.hellohao.pojo.UploadConfig; import cn.hellohao.utils.*; @@ -26,6 +27,8 @@ public class UFileImageupload { for (Map.Entry entry : fileMap.entrySet()) { String ShortUID = SetText.getShortUuid(); file = entry.getValue(); + Msg fileMiME = TypeDict.FileMiME(file); + meta.setHeader("content-type", fileMiME.getData().toString()); uFile.setContentMD5(UpYun.md5(file)); boolean result = uFile.writeFile(username + "/" + ShortUID + "." + entry.getKey(), file, true); if(result){ @@ -34,6 +37,7 @@ public class UFileImageupload { returnImage.setImgSize(entry.getValue().length()); returnImage.setCode("200"); }else{ + returnImage.setCode("400"); System.err.println("上传失败"); } } diff --git a/src/main/java/cn/hellohao/service/impl/USSImageupload.java b/src/main/java/cn/hellohao/service/impl/USSImageupload.java index e8927b6..47b8b04 100644 --- a/src/main/java/cn/hellohao/service/impl/USSImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/USSImageupload.java @@ -1,6 +1,7 @@ package cn.hellohao.service.impl; import cn.hellohao.pojo.Keys; +import cn.hellohao.pojo.Msg; import cn.hellohao.pojo.ReturnImage; import cn.hellohao.pojo.UploadConfig; import cn.hellohao.utils.*; @@ -29,6 +30,8 @@ public class USSImageupload { for (Map.Entry entry : fileMap.entrySet()) { String ShortUID = SetText.getShortUuid(); file = entry.getValue(); + Msg fileMiME = TypeDict.FileMiME(file); + meta.setHeader("content-type", fileMiME.getData().toString()); upyun.setContentMD5(UpYun.md5(file)); boolean result = upyun.writeFile(username + "/" + ShortUID + "." + entry.getKey(), file, true); if(result){ @@ -37,6 +40,7 @@ public class USSImageupload { returnImage.setImgSize(entry.getValue().length()); returnImage.setCode("200"); }else{ + returnImage.setCode("400"); System.err.println("上传失败"); } } diff --git a/src/main/java/cn/hellohao/service/impl/UploadServicel.java b/src/main/java/cn/hellohao/service/impl/UploadServicel.java index b5e44da..1920dae 100644 --- a/src/main/java/cn/hellohao/service/impl/UploadServicel.java +++ b/src/main/java/cn/hellohao/service/impl/UploadServicel.java @@ -110,7 +110,7 @@ public class UploadServicel { e.printStackTrace(); System.out.println("未获取到图片的MD5,成成UUID"); } - Msg fileMiME = TypeDict.FileMiME(file, uploadConfig.getSuffix()); + Msg fileMiME = TypeDict.FileMiME(file); if(!fileMiME.getCode().equals("200")) { //非图像文本 msg.setCode("4000"); diff --git a/src/main/java/cn/hellohao/utils/FirstRun.java b/src/main/java/cn/hellohao/utils/FirstRun.java index 65c5424..60d9784 100644 --- a/src/main/java/cn/hellohao/utils/FirstRun.java +++ b/src/main/java/cn/hellohao/utils/FirstRun.java @@ -86,11 +86,11 @@ public class FirstRun implements InitializingBean { Print.Normal("Stage 7"); } - Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+"'imgandalbum' and column_name = 'notes' and TABLE_SCHEMA='picturebed'"); - if(ret6==0){ - RunSqlScript.RunInsert(sql11); - Print.Normal("Stage 8"); - } +// Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+"'imgandalbum' and column_name = 'notes' and TABLE_SCHEMA='picturebed'"); +// if(ret6==0){ +// RunSqlScript.RunInsert(sql11); +// Print.Normal("Stage 8"); +// } RunSqlScript.RunInsert(sql10); @@ -120,7 +120,7 @@ public class FirstRun implements InitializingBean { private String sql10 = "alter table config modify column `explain` varchar(1000),modify column links varchar(1000),modify column notice varchar(1000),modify column baidu varchar(1000)"; //添加imgandalbum字段notes(添加画廊图片说明) - private String sql11 = "alter table imgandalbum add notes varchar(1000) DEFAULT ' '"; +// private String sql11 = "alter table imgandalbum add notes varchar(1000) DEFAULT ' '"; private String inddx_md5key = "ALTER TABLE imgdata ADD INDEX index_md5key_url ( md5key,imgurl)"; // create index yarn_app_result_i4 on yarn_app_result (flow_exec_id(100), another_column(50)); diff --git a/src/main/java/cn/hellohao/utils/GetIPS.java b/src/main/java/cn/hellohao/utils/GetIPS.java index a84eac7..6d59b2c 100644 --- a/src/main/java/cn/hellohao/utils/GetIPS.java +++ b/src/main/java/cn/hellohao/utils/GetIPS.java @@ -1,8 +1,6 @@ package cn.hellohao.utils; import cn.hellohao.service.impl.ImgServiceImpl; -import cn.hellohao.service.impl.ImgreviewServiceImpl; - import javax.servlet.http.HttpServletRequest; /** @@ -27,9 +25,6 @@ public class GetIPS implements Runnable { thread.start(); } - - /*** * 用于测试跨域 * @author huangweii * 2015年5月29日 */ - public static String getIpAddr(HttpServletRequest request){ String ip = request.getHeader("X-Forwarded-For"); if(org.apache.commons.lang3.StringUtils.isNotEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)){ diff --git a/src/main/java/cn/hellohao/utils/ImgUrlUtil.java b/src/main/java/cn/hellohao/utils/ImgUrlUtil.java index 43a3824..45add0b 100644 --- a/src/main/java/cn/hellohao/utils/ImgUrlUtil.java +++ b/src/main/java/cn/hellohao/utils/ImgUrlUtil.java @@ -128,7 +128,7 @@ public class ImgUrlUtil { //下载并且保存成功后 判断格式 如果不是图像格式 就删除 // if(new File(saveDir+File.separator+fileName).exists()){ - Msg msg = TypeDict.FileMiME(file,null); + Msg msg = TypeDict.FileMiME(file); if(msg.getCode().equals("200")){ File f = new File(saveDir+File.separator+fileName); String imgPath = saveDir+File.separator+fileName+"."+(msg.getData().toString().replace("image/","")); diff --git a/src/main/java/cn/hellohao/utils/TypeDict.java b/src/main/java/cn/hellohao/utils/TypeDict.java index 98d36fa..0b5d80e 100644 --- a/src/main/java/cn/hellohao/utils/TypeDict.java +++ b/src/main/java/cn/hellohao/utils/TypeDict.java @@ -69,7 +69,7 @@ MIDI (mid),文件头:4D546864 } //apache大法 - public static Msg FileMiME(File file, String suffix){ + public static Msg FileMiME(File file ){ final Msg msg = new Msg(); try { Tika tika = new Tika();