From 50fb58286ed3b718c39a97e0987ee7561a295651 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期五, 04 七月 2025 17:56:41 +0800
Subject: [PATCH] git ch

---
 server/service/src/main/java/com/doumee/core/utils/aliyun/ALiYunUtil.java |   90 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 78 insertions(+), 12 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/core/utils/aliyun/ALiYunUtil.java b/server/service/src/main/java/com/doumee/core/utils/aliyun/ALiYunUtil.java
index dfd461c..eb43b42 100644
--- a/server/service/src/main/java/com/doumee/core/utils/aliyun/ALiYunUtil.java
+++ b/server/service/src/main/java/com/doumee/core/utils/aliyun/ALiYunUtil.java
@@ -12,6 +12,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.lang3.StringUtils;
@@ -435,17 +436,17 @@
         return filename;
     }
 
-    public static void main(String[] args) throws OSSException,
-            ClientException, IOException {
-        ALiYunUtil aLiYunUtil = new ALiYunUtil("", "uc4nnpsqep1i9fijqr37nokh",
-                "/rp41xCx/XdGEVCptdH6v7xpc9w=");
-        // aLiYunUtil.uploadObject("pongto", "work/li2.txt", "D://鍝�.txt",
-        // ".html,.html text/html");D://瑁呮満杞欢/鍔炲叕瀛︿範
-        // aLiYunUtil.partUploadObject("pongto", "work/ps.exe",
-        // "D://瑁呮満杞欢/鍔炲叕瀛︿範/Adobe_Illustrator_CS6_XiaZaiBa.exe",
-        // ".html,.html text/html");
-        // aLiYunUtil.deleteBucket("pongto");
-    }
+//    public static void main(String[] args) throws OSSException,
+//            ClientException, IOException {
+//        ALiYunUtil aLiYunUtil = new ALiYunUtil("", "uc4nnpsqep1i9fijqr37nokh",
+//                "/rp41xCx/XdGEVCptdH6v7xpc9w=");
+//        // aLiYunUtil.uploadObject("pongto", "work/li2.txt", "D://鍝�.txt",
+//        // ".html,.html text/html");D://瑁呮満杞欢/鍔炲叕瀛︿範
+//        // aLiYunUtil.partUploadObject("pongto", "work/ps.exe",
+//        // "D://瑁呮満杞欢/鍔炲叕瀛︿範/Adobe_Illustrator_CS6_XiaZaiBa.exe",
+//        // ".html,.html text/html");
+//        // aLiYunUtil.deleteBucket("pongto");
+//    }
 
     /**
      * 涓婁紶缃戠粶鏂囦欢
@@ -511,7 +512,7 @@
 
     }
 
-    public boolean uploadOnlineObject(InputStream inputStream, String bucketName, String key,
+    public boolean uploadOnlineObjectNew(InputStream inputStream, String bucketName, String key,
                                       String mime) throws OSSException, ClientException, IOException {
         if (inputStream != null) {
             // 鍒ゆ柇鏄惁瀛樺湪锛屼笉瀛樺湪鍒涘缓
@@ -555,6 +556,71 @@
         return false;
 
     }
+    public static ProgressModel queryProgressModel(String id){
+        return PutObjectProgressListenerBiz.queryProgressModel(id);
+    }
+    public boolean uploadOnlineObject(InputStream inputStream, String bucketName, String key,String tempId,
+                                      long size,String mime) throws OSSException, ClientException, IOException {
+        try {
+            isExistBucket(bucketName);
+            ObjectMetadata objectMeta = new ObjectMetadata();
+            objectMeta.setContentLength(size>0?size:inputStream.available());
+            // 鍙互鍦╩etadata涓爣璁版枃浠剁被鍨�
+            if (StringUtils.isNotBlank(mime)) {
+                objectMeta.setContentType(mime);
+            }
+            PutObjectRequest putObjectRequest = null;
+            if(StringUtils.isNotBlank(tempId)){
+                ProgressModel pmodel = new ProgressModel();
+                pmodel.setKey(key);
+                pmodel.setId(tempId);
+                pmodel.setStatus(0);
+                pmodel.setStartDate(new Date());
+                pmodel.setTotalBytes(size>0?size:objectMeta.getContentLength());
+                putObjectRequest = new PutObjectRequest(bucketName, key, inputStream,objectMeta)
+                        .withProgressListener(new PutObjectProgressListenerBiz(pmodel));
+//                putObjectRequest.setProgressListener();
+            }else{
+                putObjectRequest = new PutObjectRequest(bucketName, key,
+                        inputStream);
+            }
+            PutObjectResult putObjectResult = client.putObject(putObjectRequest);
+
+            return true;
+            // 涓嬭浇鏂囦欢鐨勫悓鏃舵寚瀹氳繘搴︽潯鍙傛暟銆傛澶凣etObjectProgressListenerDemo涓鸿皟鐢ㄧ被鐨勭被鍚嶏紝璇峰湪瀹為檯浣跨敤鏃舵浛鎹负鐩稿簲鐨勭被鍚嶃��
+//            ossClient.getObject(new GetObjectRequest(bucketName,objectName).
+//                    <GetObjectRequest>withProgressListener(new GetObjectProgressListenerDemo()));
+
+        } catch (OSSException oe) {
+            System.out.println("Caught an OSSException, which means your request made it to OSS, "
+                    + "but was rejected with an error response for some reason.");
+            System.out.println("Error Message:" + oe.getErrorMessage());
+            System.out.println("Error Code:" + oe.getErrorCode());
+            System.out.println("Request ID:" + oe.getRequestId());
+            System.out.println("Host ID:" + oe.getHostId());
+        } catch (ClientException ce) {
+            System.out.println("Caught an ClientException, which means the client encountered "
+                    + "a serious internal problem while trying to communicate with OSS, "
+                    + "such as not being able to access the network.");
+            System.out.println("Error Message:" + ce.getMessage());
+        } finally {
+            if (inputStream != null) {
+                // 鍒ゆ柇鏄惁瀛樺湪锛屼笉瀛樺湪鍒涘缓
+                inputStream.close();
+            }
+            if (client != null) {
+                client.shutdown();
+            }
+        }
+
+
+        return false;
+
+    }
+
+
+
+
 
 
 }

--
Gitblit v1.9.3