From 3b8110b648d89a47a69da09e0a215cda9bab952b Mon Sep 17 00:00:00 2001 From: Darren Yu Date: Tue, 16 Sep 2025 10:33:41 +0800 Subject: [PATCH] fix(cos): traffic limit wrongly given in bytes, should be bits (#2899) --- pkg/filemanager/driver/cos/cos.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/filemanager/driver/cos/cos.go b/pkg/filemanager/driver/cos/cos.go index b87e3eee..88009953 100644 --- a/pkg/filemanager/driver/cos/cos.go +++ b/pkg/filemanager/driver/cos/cos.go @@ -382,7 +382,12 @@ func (handler Driver) Thumb(ctx context.Context, expire *time.Time, ext string, func (handler Driver) Source(ctx context.Context, e fs.Entity, args *driver.GetSourceArgs) (string, error) { // 添加各项设置 options := urlOption{} + if args.Speed > 0 { + // Byte 转换为 bit + args.Speed *= 8 + + // COS对速度值有范围限制 if args.Speed < 819200 { args.Speed = 819200 } @@ -391,6 +396,7 @@ func (handler Driver) Source(ctx context.Context, e fs.Entity, args *driver.GetS } options.Speed = args.Speed } + if args.IsDownload { encodedFilename := url.PathEscape(args.DisplayName) options.ContentDescription = fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`,