diff --git a/app/hdl/comm/hdl_comm.go b/app/hdl/comm/hdl_comm.go index 6c47499..2169265 100644 --- a/app/hdl/comm/hdl_comm.go +++ b/app/hdl/comm/hdl_comm.go @@ -168,54 +168,6 @@ func CommOss(c *gin.Context, args ImgReqUploadReq) { return } - cfgMap := make(map[string]string, len(*sysCfgs)) - for _, cfg := range *sysCfgs { - cfgMap[cfg.Key] = cfg.Val - } - endpoint := cfgMap[enum2.AliyunOssEndpoint] - bucketName := cfgMap[enum2.AliyunOssBucketName] - ossBucketScheme := cfgMap[enum2.AliyunOssBucketScheme] - accessKeyID := cfgMap[enum2.AliyunOssAccessKeyID] - accessKeySecret := cfgMap[enum2.AliyunOssAccessKeySecret] - - // 创建OSSClient实例。 - client, err := oss.New(ossBucketScheme+"://"+endpoint, accessKeyID, accessKeySecret) - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } - - // 获取存储空间。 - bucket, err := client.Bucket(bucketName) - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } - - options := []oss.Option{ - oss.ContentType(args.ContentType), - } - - signedURL, err := bucket.SignURL(args.FileName, oss.HTTPPut, 60*5, options...) - if err != nil { - e.OutErr(c, e.ERR_AES_ENCODE, err.Error()) - return - } - - e.OutSuc(c, signedURL, nil) -} -func NewCommOss(c *gin.Context, args ImgReqUploadReq) { - sysCfgDb := sys_cfg.NewSysCfgDb(db.Db) - sysCfgs, err := sysCfgDb.SysCfgGetAll() - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - if sysCfgs == nil { - e.OutErr(c, e.ERR_CFG_CACHE, nil) - return - } - cfgMap := make(map[string]string, len(*sysCfgs)) for _, cfg := range *sysCfgs { cfgMap[cfg.Key] = cfg.Val @@ -226,11 +178,9 @@ func NewCommOss(c *gin.Context, args ImgReqUploadReq) { accessKeyID := cfgMap[enum2.AliyunOssAccessKeyID] accessKeySecret := cfgMap[enum2.AliyunOssAccessKeySecret] if cfg.Prd { - accessKeyID = os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID") - accessKeySecret = os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET") + accessKeyID = os.Getenv(enum2.AliyunOssAccessKeyID) + accessKeySecret = os.Getenv(enum2.AliyunOssAccessKeySecret) } - fmt.Println("ALIBABA_CLOUD_ACCESS_KEY_ID>>>>>>>>", accessKeyID) - fmt.Println("ALIBABA_CLOUD_ACCESS_KEY_SECRET>>>>>>>>", accessKeySecret) // 创建OSSClient实例。 client, err := oss.New(ossBucketScheme+"://"+endpoint, accessKeyID, accessKeySecret) diff --git a/app/hdl/hdl_demo.go b/app/hdl/hdl_demo.go index 0db62ef..088f65a 100644 --- a/app/hdl/hdl_demo.go +++ b/app/hdl/hdl_demo.go @@ -2,7 +2,6 @@ package hdl import ( "applet/app/e" - "applet/app/hdl/comm" "applet/app/svc" "github.com/gin-gonic/gin" ) @@ -18,7 +17,7 @@ import ( // @Failure 400 {object} md.Response "具体错误" // @Router /api/demo [post] func Demo(c *gin.Context) { - var args comm.ImgReqUploadReq + var args interface{} err := c.ShouldBindJSON(&args) if err != nil { err = svc.HandleValidateErr(err) @@ -26,5 +25,9 @@ func Demo(c *gin.Context) { e.OutErr(c, err1.Code, err1.Error()) return } - comm.NewCommOss(c, args) + + e.OutSuc(c, map[string]interface{}{ + "args": args, + }, nil) + return }