浏览代码

fix:前端oss上传时,需要后端返回相关配置

Roc 1 年之前
父节点
当前提交
d74a5dab59
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      services/oss.go

+ 12 - 0
services/oss.go

@@ -117,6 +117,10 @@ type STSToken struct {
 	AccessKeySecret string
 	SecurityToken   string
 	ExpiredTime     string
+	RegionId        string
+	Bucketname      string
+	Endpoint        string
+	Imghost         string
 }
 
 // GetOssSTSToken 获取STSToken
@@ -148,6 +152,10 @@ func GetOssSTSToken() (item *STSToken, err error) {
 			item.AccessKeySecret = lastToken.AccessKeySecret
 			item.SecurityToken = lastToken.SecurityToken
 			item.ExpiredTime = lastToken.ExpiredTime
+			item.RegionId = utils.RegionId
+			item.Bucketname = utils.Bucketname
+			item.Endpoint = utils.Endpoint
+			item.Imghost = utils.Imghost
 			return
 		}
 	}
@@ -204,6 +212,10 @@ func NewSTSToken() (item *STSToken, err error) {
 		t, _ := time.Parse(time.RFC3339, response.Credentials.Expiration)
 		expiration := t.In(time.Local)
 		item.ExpiredTime = expiration.Format(utils.FormatDateTime)
+		item.RegionId = utils.RegionId
+		item.Bucketname = utils.Bucketname
+		item.Endpoint = utils.Endpoint
+		item.Imghost = utils.Imghost
 	}
 	return
 }