From 015b4f31cebbecf6f6da760ed2f8af3da721e802 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 18 四月 2025 16:17:17 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/src/main/java/com/doumee/api/common/PublicCloudController.java | 72 +++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 1 deletions(-)
diff --git a/server/src/main/java/com/doumee/api/common/PublicCloudController.java b/server/src/main/java/com/doumee/api/common/PublicCloudController.java
index e2a317a..c6105c1 100644
--- a/server/src/main/java/com/doumee/api/common/PublicCloudController.java
+++ b/server/src/main/java/com/doumee/api/common/PublicCloudController.java
@@ -66,7 +66,76 @@
@ApiOperation(value = "鎵归噺涓婁紶鏂囦欢鍒癋TP")
@RequestMapping(method= RequestMethod.POST,value="/uploadBatch")
@ResponseBody
- public void uploadBatch(HttpServletRequest request, HttpServletResponse response, String folder) throws Exception {
+ public void uploadBatch(@RequestParam("files") MultipartFile[] fileList,HttpServletRequest request, HttpServletResponse response, String folder) throws Exception {
+ if(Objects.isNull(folder)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ if(Objects.isNull(fileList)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ SystemDictData folderData = systemDictDataBiz.queryByCode(Constants.FTP,folder);
+ if(Objects.isNull(folderData)||StringUtils.isBlank(folderData.getCode())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐩爣鏂囦欢澶归敊璇�");
+ }
+ folder = systemDictDataBiz.queryByCode(Constants.FTP,folder).getCode();
+ String prefixPath = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode();
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("text/html;charset=UTF-8");
+ Map<String, Object> context = new HashMap<>();
+ try {
+ if(ftp == null){
+ ftp = new FtpUtil(systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_HOST).getCode(),
+ Integer.parseInt(systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_PORT).getCode()),
+ systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_USERNAME).getCode(),
+ systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_PWD).getCode());
+ }else{
+ ftp.connect();
+ }
+
+ context.put("success", true);
+ context.put("code", 200);
+ context.put("errno",0);
+ JSONArray jsonArray = new JSONArray();
+ if (fileList.length > 0) {
+ //閬嶅巻鏂囦欢鍒楄〃
+ Integer index = Constants.ONE;
+ for (MultipartFile file :fileList) {
+ //鑾峰緱姣忎竴涓枃浠�
+ String originname = file.getOriginalFilename();
+ InputStream is = file.getInputStream();
+ String endType = originname.substring(originname.lastIndexOf("."), originname.length());
+ String date = DateUtil.getNowShortDate();
+ String fName = date + "/" + UUID.randomUUID() + endType;
+ String fileName = folder + fName;
+ boolean r = ftp.uploadInputstreamBatch(is, fileName, Constants.equalsInteger(index ,fileList.length),index);
+ if (r) {
+ JSONObject fileJSON = new JSONObject();
+ fileJSON.put("url", prefixPath + fileName);
+ fileJSON.put("imgaddr", fName);
+ fileJSON.put("imgname", fileName);
+ fileJSON.put("originname", originname);
+ jsonArray.add(fileJSON);
+ }
+ index = index + 1;
+ }
+ context.put("data",jsonArray);
+ }
+ } catch (Exception e) {
+ log.error("銆愪笂浼燜TP澶辫触銆�======================"+e.getMessage());
+ context.put("code", 0);
+ context.put("message", "涓婁紶澶辫触");
+ context.put("errno",0);
+ writerJson(response, context);
+ return;
+
+ }
+ writerJson(response, context);
+ return;
+ }
+ @ApiOperation(value = "鎵归噺涓婁紶鏂囦欢鍒癋TP")
+ @RequestMapping(method= RequestMethod.POST,value="/uploadBatchOld")
+ @ResponseBody
+ public void uploadBatchOld( HttpServletRequest request, HttpServletResponse response, String folder) throws Exception {
if(Objects.isNull(folder)){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
@@ -192,6 +261,7 @@
Iterator<String> it = multipartRequest.getFileNames();
while (it.hasNext()) {
MultipartFile file = multipartRequest.getFile(it.next());
+ System.out.println(file.getSize());
String originname = file.getOriginalFilename();
is = file.getInputStream();
String endType = ".jpg";
--
Gitblit v1.9.3