Fix: missing x-oss-process params in thumb url in public oss bucket

This commit is contained in:
HFO4
2020-02-01 14:36:57 +08:00
parent 8bb2c2b0c5
commit b1490a665c
2 changed files with 10 additions and 3 deletions

View File

@@ -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
}