diff --git a/coolstore-partner-webc/coolstore-partner-webc.iml b/coolstore-partner-webc/coolstore-partner-webc.iml
index a91efa453..ed92ed8d1 100644
--- a/coolstore-partner-webc/coolstore-partner-webc.iml
+++ b/coolstore-partner-webc/coolstore-partner-webc.iml
@@ -80,12 +80,7 @@
-
-
-
-
-
@@ -135,5 +130,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/coolstore-partner-webc/pom.xml b/coolstore-partner-webc/pom.xml
index 0acf08c8c..fe65b122a 100644
--- a/coolstore-partner-webc/pom.xml
+++ b/coolstore-partner-webc/pom.xml
@@ -29,6 +29,10 @@
org.springframework.boot
spring-boot-starter
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+
diff --git a/coolstore-partner-webc/src/main/java/com/cool/store/controller/OssClientController.java b/coolstore-partner-webc/src/main/java/com/cool/store/controller/OssClientController.java
new file mode 100644
index 000000000..856583cca
--- /dev/null
+++ b/coolstore-partner-webc/src/main/java/com/cool/store/controller/OssClientController.java
@@ -0,0 +1,65 @@
+package com.cool.store.controller;
+
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.common.utils.BinaryUtil;
+import com.aliyun.oss.model.MatchMode;
+import com.aliyun.oss.model.PolicyConditions;
+import com.cool.store.response.ResponseResult;
+import com.cool.store.vo.oss.OssUploadConfigVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.sql.Date;
+
+/**
+ * @author zhangchenbiao
+ * @FileName: OssClientController
+ * @Description:
+ * @date 2023-06-01 11:25
+ */
+@RestController
+@RequestMapping({"/oss"})
+@Slf4j
+public class OssClientController {
+
+ @Value("${oss.accessKeyId:null}")
+ private String accessKeyId;
+ @Value("${oss.accessKeySecret:null}")
+ private String accessKeySecret;
+ @Value("${oss.endpoint:null}")
+ private String endpoint;
+ @Value("${oss.bucket:null}")
+ private String bucket;
+ @Value("${corp.id:null}")
+ private String corpId;
+
+ @GetMapping("/getUploadFileConfig")
+ public ResponseResult getUploadFileConfig(){
+ // host的格式为 bucketname.endpoint
+ String host = "http://" + bucket + "." + endpoint;
+ // 用户上传文件时指定的前缀。
+ String dir = "partner/" + corpId + "/";
+
+ OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret);
+ try {
+ long expireTime = 300;
+ long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
+ Date expiration = new Date(expireEndTime);
+ PolicyConditions policyConds = new PolicyConditions();
+ policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, 1048576000);
+ policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
+ String postPolicy = client.generatePostPolicy(expiration, policyConds);
+ byte[] binaryData = postPolicy.getBytes("utf-8");
+ String encodedPolicy = BinaryUtil.toBase64String(binaryData);
+ String signature = client.calculatePostSignature(postPolicy);
+ OssUploadConfigVO result = new OssUploadConfigVO(accessKeyId, encodedPolicy, signature, dir, host, String.valueOf(expireEndTime / 1000));
+ return ResponseResult.success(result);
+ }catch (Exception e){
+ log.info("exception", e);
+ }
+ return ResponseResult.success();
+ }
+}