Fix: missing x-oss-process params in thumb url in public oss bucket
This commit is contained in:
parent
8bb2c2b0c5
commit
b1490a665c
2 changed files with 10 additions and 3 deletions
|
@ -179,6 +179,7 @@ func (handler Driver) Thumb(ctx context.Context, path string) (*response.Content
|
|||
}
|
||||
|
||||
thumbParam := fmt.Sprintf("image/resize,m_lfit,h_%d,w_%d", thumbSize[1], thumbSize[0])
|
||||
ctx = context.WithValue(ctx, fsctx.ThumbSizeCtx, thumbParam)
|
||||
thumbOption := []oss.Option{oss.Process(thumbParam)}
|
||||
thumbURL, err := handler.signSourceURL(
|
||||
ctx,
|
||||
|
@ -248,6 +249,12 @@ func (handler Driver) signSourceURL(ctx context.Context, path string, ttl int64,
|
|||
return "", err
|
||||
}
|
||||
sourceURL := cdnURL.ResolveReference(file)
|
||||
|
||||
// 如果有缩略图设置
|
||||
if thumbSize, ok := ctx.Value(fsctx.ThumbSizeCtx).(string); ok {
|
||||
sourceURL.RawQuery = "x-oss-process=" + thumbSize
|
||||
}
|
||||
|
||||
return sourceURL.String(), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ func TestCheckSettingValue(t *testing.T) {
|
|||
func TestBuildSiteConfig(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
|
||||
res := BuildSiteConfig(map[string]string{"not exist": ""}, nil)
|
||||
res := BuildSiteConfig(map[string]string{"not exist": ""}, &model.User{})
|
||||
asserts.Equal("", res.Data.(SiteConfig).SiteName)
|
||||
|
||||
res = BuildSiteConfig(map[string]string{"siteName": "123"}, nil)
|
||||
res = BuildSiteConfig(map[string]string{"siteName": "123"}, &model.User{})
|
||||
asserts.Equal("123", res.Data.(SiteConfig).SiteName)
|
||||
|
||||
res = BuildSiteConfig(map[string]string{"qq_login": "1"}, nil)
|
||||
res = BuildSiteConfig(map[string]string{"qq_login": "1"}, &model.User{})
|
||||
asserts.Equal(true, res.Data.(SiteConfig).QQLogin)
|
||||
asserts.Equal(uint(0), res.Data.(SiteConfig).User.ID)
|
||||
|
||||
|
|
Loading…
Reference in a new issue