From ce46b005f09b2fbb894ffea1e06bc2d90da98be7 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Wed, 25 Dec 2024 13:39:40 +0800 Subject: [PATCH] update get oss key --- app/hdl/comm/hdl_comm.go | 6 ++++++ app/hdl/hdl_demo.go | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/hdl/comm/hdl_comm.go b/app/hdl/comm/hdl_comm.go index 5a3d5e2..dc57d99 100644 --- a/app/hdl/comm/hdl_comm.go +++ b/app/hdl/comm/hdl_comm.go @@ -1,6 +1,7 @@ package comm import ( + "applet/app/cfg" "applet/app/db" "applet/app/e" "applet/app/md" @@ -14,6 +15,7 @@ import ( "fmt" "github.com/aliyun/aliyun-oss-go-sdk/oss" "github.com/gin-gonic/gin" + "os" "time" ) @@ -57,6 +59,10 @@ func GetOssUrl(c *gin.Context) { ossBucketScheme := cfgMap[enum2.AliyunOssBucketScheme] accessKeyID := cfgMap[enum2.AliyunOssAccessKeyID] accessKeySecret := cfgMap[enum2.AliyunOssAccessKeySecret] + if cfg.Prd { + accessKeyID = os.Getenv(enum2.AliyunOssAccessKeyID) + accessKeySecret = os.Getenv(enum2.AliyunOssAccessKeySecret) + } // 创建OSSClient实例。 client, err := oss.New(ossBucketScheme+"://"+endpoint, accessKeyID, accessKeySecret) diff --git a/app/hdl/hdl_demo.go b/app/hdl/hdl_demo.go index 0143a13..dda2534 100644 --- a/app/hdl/hdl_demo.go +++ b/app/hdl/hdl_demo.go @@ -7,6 +7,7 @@ import ( "applet/app/lib/aes/md" "applet/app/svc" "applet/app/utils" + "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" "encoding/json" "fmt" "github.com/gin-gonic/gin" @@ -53,8 +54,8 @@ func Demo1(c *gin.Context) { //es.CreateIndexIfNotExists(md2.EggUserShortLink, md2.EggUserShortLinkMap) data := make(map[string]string) if cfg.Prd { - data["aliyun_sms_id"] = os.Getenv("aliyun_sms_id") - data["aliyun_sms_secret"] = os.Getenv("aliyun_sms_secret") + data["access_key_id"] = os.Getenv(enum.AliyunOssAccessKeyID) + data["access_key_secret"] = os.Getenv(enum.AliyunOssAccessKeySecret) } e.OutSuc(c, data, nil) }