From a7daa6060b2fbf2f2130dc25b7972ad10e2db42e Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 10 十一月 2023 10:40:05 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/common.js |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/main/webapp/static/js/common.js b/src/main/webapp/static/js/common.js
index 8d34c57..28bf7c3 100644
--- a/src/main/webapp/static/js/common.js
+++ b/src/main/webapp/static/js/common.js
@@ -289,7 +289,7 @@
 }
 
 //涓婁紶鏂囦欢鑷砄SS
-async function putObject(file) {
+async function putObject(file, uploadProgress) {
     var client = getOssClient()
     if (client == null) {
         return false;
@@ -297,21 +297,34 @@
 
     var filename = dateToStr2(new Date()) + "_" + file.name
 
-    // 濉啓Object瀹屾暣璺緞銆侽bject瀹屾暣璺緞涓笉鑳藉寘鍚獴ucket鍚嶇О銆�
-    // 鎮ㄥ彲浠ラ�氳繃鑷畾涔夋枃浠跺悕锛堜緥濡俥xampleobject.txt锛夋垨鏂囦欢瀹屾暣璺緞锛堜緥濡俥xampledir/exampleobject.txt锛夌殑褰㈠紡瀹炵幇灏嗘暟鎹笂浼犲埌褰撳墠Bucket鎴朆ucket涓殑鎸囧畾鐩綍銆�
-    // data瀵硅薄鍙互鑷畾涔変负file瀵硅薄銆丅lob鏁版嵁鎴栬�匫SS Buffer銆�
+    // // 濉啓Object瀹屾暣璺緞銆侽bject瀹屾暣璺緞涓笉鑳藉寘鍚獴ucket鍚嶇О銆�
+    // // 鎮ㄥ彲浠ラ�氳繃鑷畾涔夋枃浠跺悕锛堜緥濡俥xampleobject.txt锛夋垨鏂囦欢瀹屾暣璺緞锛堜緥濡俥xampledir/exampleobject.txt锛夌殑褰㈠紡瀹炵幇灏嗘暟鎹笂浼犲埌褰撳墠Bucket鎴朆ucket涓殑鎸囧畾鐩綍銆�
+    // // data瀵硅薄鍙互鑷畾涔変负file瀵硅薄銆丅lob鏁版嵁鎴栬�匫SS Buffer銆�
+    // const options = {
+    //     meta: {temp: "demo"},
+    //     mime: "json",
+    //     headers: {"Content-Type": "text/plain"},
+    // };
+    //
+    // return await client.put(filename, file, options);
+
     const options = {
-        meta: {temp: "demo"},
-        mime: "json",
-        headers: {"Content-Type": "text/plain"},
+        // 鑾峰彇鍒嗙墖涓婁紶杩涘害銆佹柇鐐瑰拰杩斿洖鍊笺��
+        progress: (p, cpt, res) => {
+            // console.log(p);
+            uploadProgress(p)//鍥炶皟涓婁紶杩涘害
+        },
+        // 璁剧疆骞跺彂涓婁紶鐨勫垎鐗囨暟閲忋��
+        parallel: 4,
+        // 璁剧疆鍒嗙墖澶у皬銆傞粯璁ゅ�间负1 MB锛屾渶灏忓�间负100 KB銆�
+        partSize: 1024 * 1024,
+        // headers,
+        // 鑷畾涔夊厓鏁版嵁锛岄�氳繃HeadObject鎺ュ彛鍙互鑾峰彇Object鐨勫厓鏁版嵁銆�
+        meta: {year: 2020, people: "test"},
+        mime: "text/plain",
     };
 
-    return await client.put(filename, file, options);
-    // client.put(filename, file, options).then((e) => {
-    //     return true;
-    // }).catch((e) => {
-    //     return false;
-    // })
+    return await client.multipartUpload(filename, file, {...options});
 }
 
 //鑾峰彇OSS鏂囦欢URL

--
Gitblit v1.9.1