diff --git a/Tbed.7z b/Tbed.7z new file mode 100644 index 0000000..cc15e1f Binary files /dev/null and b/Tbed.7z differ diff --git a/src/main/java/cn/hellohao/TbedApplication.java b/src/main/java/cn/hellohao/TbedApplication.java index 0ca8af2..60af641 100644 --- a/src/main/java/cn/hellohao/TbedApplication.java +++ b/src/main/java/cn/hellohao/TbedApplication.java @@ -23,18 +23,6 @@ public class TbedApplication { public static void main(String[] args) { SpringApplication.run(TbedApplication.class, args); - - Scanner scanner = new Scanner(System.in); -// Print.Normal("请输入密钥:"); -// String in = scanner.nextLine(); -// if(in.equals("111")){ -// Print.Normal("正确,进入"); -// }else{ -// Print.warning("错误,退出"); -// } - - - } /** * 文件上传配置 diff --git a/src/main/java/cn/hellohao/controller/ClientController.java b/src/main/java/cn/hellohao/controller/ClientController.java index 4a20c88..0e8ed22 100644 --- a/src/main/java/cn/hellohao/controller/ClientController.java +++ b/src/main/java/cn/hellohao/controller/ClientController.java @@ -61,13 +61,15 @@ public class ClientController { UploadConfig uploadConfig = uploadConfigService.getUpdateConfig(); if (uploadConfig.getApi() == 1) { if (email != null && pass != null) { - Integer ret = userService.login(email, pass); + Integer ret = userService.login(email, Base64Encryption.encryptBASE64(pass.getBytes())); if (ret > 0) { User user = userService.getUsers(email); if (user.getIsok() == 1) { User u = userService.getUsers(email); Config config = configService.getSourceype();//查询当前系统使用的存储源类型。 + Integer Sourcekey = GetCurrentSource.GetSource(u.getId()); + Keys key = keysService.selectKeys(Sourcekey); if (key.getStorageType() != 0 && key.getStorageType() != null) { if (key.getStorageType() == 1) { diff --git a/src/main/java/cn/hellohao/controller/UpdateImgController.java b/src/main/java/cn/hellohao/controller/UpdateImgController.java index 5b33011..0775399 100644 --- a/src/main/java/cn/hellohao/controller/UpdateImgController.java +++ b/src/main/java/cn/hellohao/controller/UpdateImgController.java @@ -248,7 +248,24 @@ public class UpdateImgController { Config config = configService.getSourceype();//查询当前系统使用的存储源类型。 UploadConfig uploadConfig = uploadConfigService.getUpdateConfig(); User u = (User) session.getAttribute("user"); - Integer Sourcekey = GetCurrentSource.GetSource(u.getId()); + + Integer usermemory =0; + Integer memory =0; + Integer Sourcekey=0; + if(u==null){ + Sourcekey = GetCurrentSource.GetSource(null); + memory = uploadConfig.getVisitormemory(); + usermemory= imgService.getusermemory(0); + if(usermemory==null){usermemory = 0;} + }else{ + Sourcekey = GetCurrentSource.GetSource(u.getId()); + memory = userService.getUsers(u.getEmail()).getMemory(); + usermemory= imgService.getusermemory(u.getId()); + if(usermemory==null){usermemory = 0;} + } + + + //Integer Sourcekey = GetCurrentSource.GetSource(u.getId()); String userpath = "tourist"; if(uploadConfig.getUrltype()==2){ java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy/MM/dd"); @@ -266,9 +283,9 @@ public class UpdateImgController { bo =true; }else{bo = StringUtils.doNull(Sourcekey,key);//判断对象是否有空值 } - //容量判断 - Integer usermemory =0; - Integer memory =0; +// //容量判断 +// Integer usermemory =0; +// Integer memory =0; if(u==null){ memory = uploadConfig.getVisitormemory(); usermemory= imgService.getusermemory(0); diff --git a/src/main/java/cn/hellohao/utils/AfterServiceStarted.java b/src/main/java/cn/hellohao/utils/AfterServiceStarted.java index fa6445b..8647d8e 100644 --- a/src/main/java/cn/hellohao/utils/AfterServiceStarted.java +++ b/src/main/java/cn/hellohao/utils/AfterServiceStarted.java @@ -14,7 +14,7 @@ public class AfterServiceStarted implements ApplicationRunner { */ @Override public void run(ApplicationArguments args) throws Exception { -// Print.Normal("______________________________________________"); + Print.Normal("______________________________________________"); // Print.Normal(" Hellohao-Pro "); // Print.Normal(" Successful startup of the program "); // Print.Normal(" is OK! Open http://your ip:port "); diff --git a/src/main/java/cn/hellohao/utils/LocUpdateImg.java b/src/main/java/cn/hellohao/utils/LocUpdateImg.java index 1a71b20..92a1a8c 100644 --- a/src/main/java/cn/hellohao/utils/LocUpdateImg.java +++ b/src/main/java/cn/hellohao/utils/LocUpdateImg.java @@ -36,9 +36,7 @@ public class LocUpdateImg { dest.getParentFile().mkdirs(); } try { - MultipartFile multipartFile = entry.getValue(); - FileInputStream fileInputStream = (FileInputStream) multipartFile.getInputStream(); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest)); byte[] bs = new byte[1024]; @@ -61,23 +59,20 @@ public class LocUpdateImg { return ImgUrl; }else{ Map ImgUrl = new HashMap<>(); - for (Map.Entry entry : fileMap2.entrySet()) { String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5);//生成一个没有-的uuid,然后取前5位 java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); String oldfilePath = entry.getValue(); - - String newfilePath = File.separator + "HellohaoData" + File.separator + username + File.separator+ uuid+times + "." + entry.getKey();// File file = new File(oldfilePath); File targetFile =new File(newfilePath); if(!targetFile.getParentFile().exists()) { targetFile.mkdirs(); } + file.renameTo(new File(newfilePath));//只移动,源目录不存在文件 // 例2:采用数据流模式上传文件(节省内存),自动创建父级目录 - //upyun.setContentMD5(UpYun.md5(new File(imgurl))); ReturnImage returnImage = new ReturnImage(); returnImage.setImgurl(username + "/" + uuid+times + "." + entry.getKey()); ImgUrl.put( returnImage, ImgUrlUtil.getFileSize2(new File(newfilePath))); @@ -101,24 +96,44 @@ public class LocUpdateImg { //file = SetFiles.changeFile(entry.getValue()); // 上传文件流。 System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); - ReturnImage returnImage = new ReturnImage(); + ReturnImage returnImage = new ReturnImage(); if(entry.getValue().getSize()/1024<=uploadConfig.getFilesizeuser()*1024){ File dest = new File(filePath + username + File.separator+ uuid+times + "." + entry.getKey()); if (!dest.getParentFile().exists()) { dest.getParentFile().mkdirs(); } +// try { +// entry.getValue().transferTo(dest); +// returnImage.setImgname(entry.getValue().getOriginalFilename()); +// returnImage.setImgurl(username + "/" + uuid+times + "." + entry.getKey()); +// ImgUrl.put(returnImage, (int) (entry.getValue().getSize())); +// } catch (IOException e) { +// e.printStackTrace(); +// System.err.println("上传失败"); +// } + try { - entry.getValue().transferTo(dest); + MultipartFile multipartFile = entry.getValue(); + FileInputStream fileInputStream = (FileInputStream) multipartFile.getInputStream(); + BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest)); + byte[] bs = new byte[1024]; + int len; + while ((len = fileInputStream.read(bs)) != -1) { + bos.write(bs, 0, len); + } + bos.flush(); + bos.close(); + + //ReturnImage returnImage = new ReturnImage(); returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(username + "/" + uuid+times + "." + entry.getKey()); ImgUrl.put(returnImage, (int) (entry.getValue().getSize())); - //ImgUrl.put(username + "/" + uuid+times + "." + entry.getKey(), (int) (entry.getValue().getSize())); } catch (IOException e) { e.printStackTrace(); System.err.println("上传失败"); } + }else{ - //ImgUrl.put("文件超出系统设定大小,不得超过"+uploadConfig.getFilesizeuser()+"M", -1); returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl("文件超出系统设定大小,不得超过"); ImgUrl.put(returnImage,-1); diff --git a/src/main/resources/static/static/js/webuploader.js b/src/main/resources/static/static/js/webuploader.js index ae56412..a1ae217 100644 --- a/src/main/resources/static/static/js/webuploader.js +++ b/src/main/resources/static/static/js/webuploader.js @@ -7,6 +7,8 @@ * AMD API 内部的简单不完全实现,请忽略。只有当WebUploader被合并成一个文件的时候才会引入。 */ (function( root, factory ) { + + var count = 0; var modules = {}, // 内部require, 简单不完全实现。 @@ -3620,9 +3622,11 @@ tr.setRequestHeader( headers ); tr.send(); }, - + + // 完成上传。 _finishFile: function( file, ret, hds ) { + count = 0; var owner = this.owner; return owner @@ -3704,7 +3708,7 @@ api.addValidator( 'fileNumLimit', function() { var uploader = this, opts = uploader.options, - count = 0, + max = opts.fileNumLimit >> 0, flag = true; @@ -3713,7 +3717,7 @@ } uploader.on( 'beforeFileQueued', function() { - + if ( count >= max && flag ) { flag = false; this.trigger( 'error', 'Q_EXCEED_NUM_LIMIT', max ); diff --git a/src/main/resources/static/webuploade/js/webuploader.js b/src/main/resources/static/webuploade/js/webuploader.js index e1a483b..a4b7299 100644 --- a/src/main/resources/static/webuploade/js/webuploader.js +++ b/src/main/resources/static/webuploade/js/webuploader.js @@ -6,7 +6,9 @@ * * AMD API 内部的简单不完全实现,请忽略。只有当WebUploader被合并成一个文件的时候才会引入。 */ +var count2 = 0; (function( root, factory ) { + var modules = {}, // 内部require, 简单不完全实现。 @@ -4090,6 +4092,7 @@ // 完成上传。 _finishFile: function( file, ret, hds ) { + count2 = 0; var owner = this.owner; return owner @@ -4192,7 +4195,7 @@ api.addValidator( 'fileNumLimit', function() { var uploader = this, opts = uploader.options, - count = 0, + // count = 0, max = parseInt( opts.fileNumLimit, 10 ), flag = true; @@ -4202,7 +4205,7 @@ uploader.on( 'beforeFileQueued', function( file ) { - if ( count >= max && flag ) { + if ( count2 >= max && flag ) { flag = false; this.trigger( 'error', 'Q_EXCEED_NUM_LIMIT', max, file ); setTimeout(function() { @@ -4210,19 +4213,19 @@ }, 1 ); } - return count >= max ? false : true; + return count2 >= max ? false : true; }); uploader.on( 'fileQueued', function() { - count++; + count2++; }); uploader.on( 'fileDequeued', function() { - count--; + count2--; }); uploader.on( 'reset', function() { - count = 0; + count2 = 0; }); });