diff --git a/backend/azure/azure.go b/backend/azure/azure.go index 8d408e3..b5716eb 100644 --- a/backend/azure/azure.go +++ b/backend/azure/azure.go @@ -692,12 +692,7 @@ func (az *Azure) CopyObject(ctx context.Context, input *s3.CopyObjectInput) (*s3 return nil, err } - cpSrc := *input.CopySource - if cpSrc[0] == '/' { - cpSrc = cpSrc[1:] - } - - if strings.Join([]string{*input.Bucket, *input.Key}, "/") == cpSrc && isMetaSame(mdmap, input.Metadata) { + if strings.Join([]string{*input.Bucket, *input.Key}, "/") == *input.CopySource && isMetaSame(mdmap, input.Metadata) { return nil, s3err.GetAPIError(s3err.ErrInvalidCopyDest) } @@ -711,7 +706,7 @@ func (az *Azure) CopyObject(ctx context.Context, input *s3.CopyObjectInput) (*s3 return nil, err } - resp, err := bclient.CopyFromURL(ctx, az.serviceURL+"/"+cpSrc, &blob.CopyFromURLOptions{ + resp, err := bclient.CopyFromURL(ctx, az.serviceURL+"/"+*input.CopySource, &blob.CopyFromURLOptions{ BlobTags: tags, Metadata: parseMetadata(input.Metadata), }) diff --git a/backend/posix/posix.go b/backend/posix/posix.go index 850de7c..11aaef8 100644 --- a/backend/posix/posix.go +++ b/backend/posix/posix.go @@ -1983,13 +1983,7 @@ func (p *Posix) CopyObject(ctx context.Context, input *s3.CopyObjectInput) (*s3. if input.ExpectedBucketOwner == nil { return nil, s3err.GetAPIError(s3err.ErrInvalidRequest) } - - cpSrc := *input.CopySource - if cpSrc[0] == '/' { - cpSrc = cpSrc[1:] - } - - srcBucket, srcObject, ok := strings.Cut(cpSrc, "/") + srcBucket, srcObject, ok := strings.Cut(*input.CopySource, "/") if !ok { return nil, s3err.GetAPIError(s3err.ErrInvalidCopySource) } diff --git a/s3api/controllers/base.go b/s3api/controllers/base.go index 4fd6fa6..9415aab 100644 --- a/s3api/controllers/base.go +++ b/s3api/controllers/base.go @@ -1535,6 +1535,9 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error { // Copy source headers copySource := ctx.Get("X-Amz-Copy-Source") + if len(copySource) > 0 && copySource[0] == '/' { + copySource = copySource[1:] + } copySrcIfMatch := ctx.Get("X-Amz-Copy-Source-If-Match") copySrcIfNoneMatch := ctx.Get("X-Amz-Copy-Source-If-None-Match") copySrcModifSince := ctx.Get("X-Amz-Copy-Source-If-Modified-Since")