diff --git a/enum/sys_cfg.go b/enum/sys_cfg.go index 6960a19..19d0eef 100644 --- a/enum/sys_cfg.go +++ b/enum/sys_cfg.go @@ -50,6 +50,8 @@ const ( AliyunOssAccessKeySecret = "oss_access_key_secret" AliyunOssDomain = "oss_domain" AliyunOptions = "oss_options" + AliyunOssAccountId = "oss_account_id" + AliyunOssRoleName = "oss_role_name" ) func (gt AliyunOss) String() string { @@ -68,6 +70,10 @@ func (gt AliyunOss) String() string { return "oss域名" case AliyunOptions: return "文件上传类型" + case AliyunOssAccountId: + return "阿里云账户id" + case AliyunOssRoleName: + return "oss RAM角色名称" default: return "未知" diff --git a/svc/svc_file_img_format.go b/svc/svc_file_img_format.go index 89b15cb..6aec054 100644 --- a/svc/svc_file_img_format.go +++ b/svc/svc_file_img_format.go @@ -30,6 +30,17 @@ func ImageFormatWithBucketNew(scheme, domain, name string) string { return name } - name = strings.ReplaceAll(name, "{{host}}", "") + name = strings.ReplaceAll(name, "{{tempHost}}", "") return fmt.Sprintf("%s://%s/%s", scheme, domain, name) } + +// ImageFormatWithBucketForDataInfo is 格式化成oss 域名 (只格式化内容中的 url) +func ImageFormatWithBucketForDataInfo(scheme, domain, name string) string { + if strings.Contains(name, "http") { + return name + } + + prefix := fmt.Sprintf("%s://%s/", scheme, domain) + name = strings.ReplaceAll(name, "{{tempHost}}", prefix) + return name +}