Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc21335

Browse files
committed
cdn 域名修改
1 parent a49bd89 commit fc21335

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

config/env.sample.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ activate_sign_salt = Gj&NaEqio1Tv2&4&3$
6666
access_key = xxxxxx
6767
secret_key = xxxxxxx
6868
bucket_name = xxxx
69-
up_host = up-z1.qiniu.com
69+
up_host = xxx
7070
; CND HTTP 的域名
7171
http_domain = xxx
7272
; CND HTTPS 的域名

src/http/controller/image.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"net/http"
1515
"os"
1616
"path/filepath"
17+
"strings"
1718

1819
. "http"
1920

@@ -128,6 +129,9 @@ func (ImageController) Upload(ctx echo.Context) error {
128129
if goutils.MustBool(ctx.Request().Header().Get("X-Https")) {
129130
cdnDomain = global.App.CDNHttps
130131
}
132+
if !strings.HasSuffix(cdnDomain, "/") {
133+
cdnDomain += "/"
134+
}
131135

132136
path, err := logic.DefaultUploader.UploadImage(ctx, file, imgDir, buf, filepath.Ext(fileHeader.Filename))
133137
if err != nil {
@@ -153,6 +157,9 @@ func (ImageController) Transfer(ctx echo.Context) error {
153157
if goutils.MustBool(ctx.Request().Header().Get("X-Https")) {
154158
cdnDomain = global.App.CDNHttps
155159
}
160+
if !strings.HasSuffix(cdnDomain, "/") {
161+
cdnDomain += "/"
162+
}
156163

157164
return success(ctx, map[string]interface{}{"url": cdnDomain + path})
158165
}

0 commit comments

Comments
 (0)