From 67c98cdd79a1e473fe95ddc1c695ed162c176510 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期二, 15 七月 2025 15:40:59 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 server/services/src/main/java/com/doumee/api/common/PublicCloudController.java |   72 ++++++++++++++++++++++++++++++++----
 1 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/api/common/PublicCloudController.java b/server/services/src/main/java/com/doumee/api/common/PublicCloudController.java
index e709502..738848c 100644
--- a/server/services/src/main/java/com/doumee/api/common/PublicCloudController.java
+++ b/server/services/src/main/java/com/doumee/api/common/PublicCloudController.java
@@ -54,18 +54,74 @@
     @Autowired
     private SystemDictDataBiz systemDictDataBiz;
 
-    @ApiOperation(value = "涓婁紶", notes = "涓婁紶", httpMethod = "POST", position = 6)
+    @ApiOperation(value = "涓婁紶OBS", notes = "涓婁紶OBS", httpMethod = "POST", position = 6)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "folder", value = "鏂囦欢澶�", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class),
             @ApiImplicitParam(name = "file", value = "鏂囦欢澶�", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class),
     })
-    @PostMapping(value = "/uploadLocal", headers = "content-type=multipart/form-data")
-    public void uploadLocal(HttpServletRequest request, HttpServletResponse response) throws Exception {
-        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-        uploadFileLocal(multipartRequest, response,
-                systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.IMG_DIR).getCode() ,
-                systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.FILE_DIR).getCode());
-
+    @PostMapping(value = "/upload", headers = "content-type=multipart/form-data")
+    @ResponseBody
+    public void upload(HttpServletRequest request, HttpServletResponse response, String folder) throws Exception {
+        Date d1 = new Date();
+        log.error("鎬诲緱涓婁紶鏂囦欢鎴愬姛=============寮�濮�========="+DateUtil.getPlusTime2(d1));
+        if(Objects.isNull(folder)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐩爣鏂囦欢澶归敊璇�");
+        }
+        String prefixPath = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode();
+        InputStream is = null;
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("text/html;charset=UTF-8");
+        Map<String, Object> context = new HashMap<>();
+        try {
+            CommonsMultipartResolver multipartResovler = new CommonsMultipartResolver();
+            if (multipartResovler.isMultipart(request)) {
+                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+                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";
+                    if(originname.indexOf(".")>0){
+                        endType=originname.substring(originname.lastIndexOf("."),originname.length());
+                    }
+                    String date = DateUtil.getNowShortDate();
+                    String fName =  date+"/"+ UUID.randomUUID()+endType;
+                    String fileName = folder+"/"+fName;
+                    boolean r =false;
+                    ObsUtil obsUtil = new ObsUtil( systemDictDataBiz.queryByCode(Constants.HWY_OBS,Constants.HWY_OBS_ACCESSID).getCode(),
+                            systemDictDataBiz.queryByCode(Constants.HWY_OBS,Constants.HWY_OBS_ACCESSKEY).getCode(),
+                            systemDictDataBiz.queryByCode(Constants.HWY_OBS,Constants.HWY_OBS_ENDPOINT).getCode());
+                    r = obsUtil.uploadFile( systemDictDataBiz.queryByCode(Constants.HWY_OBS,Constants.HWY_OBS_BUCKET).getCode(),is,fileName);//涓婁紶
+                    if(r){
+                        context.put("success", true);
+                        context.put("code", 200);
+                        context.put("errno",0);
+                        JSONObject fileJSON = new JSONObject();
+//                        fileJSON.put("prefixPath", prefixPath);
+//                        fileJSON.put("folder", folder);
+                        fileJSON.put("url", prefixPath+fileName);
+                        fileJSON.put("imgaddr", fName);
+                        fileJSON.put("imgname", fileName);
+                        fileJSON.put("originname", originname);
+                        context.put("data",fileJSON);
+                        context.put("message","璇锋眰鎴愬姛");
+                        writerJson(response, context);
+                        Date d2= new Date();
+                        log.error("鎬荤殑涓婁紶鏂囦欢鎴愬姛=============缁撴潫========="+DateUtil.getPlusTime2(d2) +"鑰楁椂绉掞細"+( (d2.getTime()-d1.getTime()) /1000));
+                        return;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("銆愪笂浼燜TP澶辫触銆�======================"+e.getMessage());
+        }
+        context.put("code", 0);
+        context.put("message", "涓婁紶澶辫触");
+        context.put("errno",0);
+        writerJson(response, context);
+        return;
     }
 
 

--
Gitblit v1.9.3