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 cabd835..07d61da 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,6 +54,8 @@ func Demo1(c *gin.Context) { //es.CreateIndexIfNotExists(md2.EggUserShortLink, md2.EggUserShortLinkMap) data := make(map[string]string) if cfg.Prd { + data["access_key_id"] = os.Getenv(enum.AliyunOssAccessKeyID) + data["access_key_secret"] = os.Getenv(enum.AliyunOssAccessKeySecret) data["aliyun_sms_id"] = os.Getenv("aliyun_sms_id") data["aliyun_sms_secret"] = os.Getenv("aliyun_sms_secret") data["oss_access_key_id"] = os.Getenv("oss_access_key_id")