From 99f39410f2aa34793f047fbe781bc03f726b4a35 Mon Sep 17 00:00:00 2001 From: Jiang Xiang <869914918@qq.com> Date: Mon, 27 Jan 2025 20:23:13 +0800 Subject: [PATCH] fix(s3): escape CopySource request header when copying files (#7860 close #7858) --- drivers/s3/util.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/s3/util.go b/drivers/s3/util.go index 31e658bd..99f271aa 100644 --- a/drivers/s3/util.go +++ b/drivers/s3/util.go @@ -4,6 +4,7 @@ import ( "context" "errors" "net/http" + "net/url" "path" "strings" @@ -198,7 +199,7 @@ func (d *S3) copyFile(ctx context.Context, src string, dst string) error { dstKey := getKey(dst, false) input := &s3.CopyObjectInput{ Bucket: &d.Bucket, - CopySource: aws.String("/" + d.Bucket + "/" + srcKey), + CopySource: aws.String(url.PathEscape("/" + d.Bucket + "/" + srcKey)), Key: &dstKey, } _, err := d.client.CopyObject(input)