From 64ea94c1a4e9d7a104b393a17d2e883593e20809 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Fri, 22 Dec 2017 16:27:19 -0500 Subject: [PATCH] s3: Use rest.URLEscape rather than url.QueryEscape. The X-Amz-Copy-Source takes a path. url.QueryEscape escapes spaces with a plus sign while rest.URLEscape (which mimics the url.PathEscape available from go 1.8) uses '%20' This works around an issue when copying objects with spaces in their key on DigitalOcean Spaces. --- s3/s3.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s3/s3.go b/s3/s3.go index 4d88752f6..b95193b28 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -17,7 +17,6 @@ import ( "fmt" "io" "net/http" - "net/url" "path" "regexp" "strings" @@ -36,6 +35,7 @@ import ( "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3manager" "github.com/ncw/rclone/fs" + "github.com/ncw/rclone/rest" "github.com/ncw/swift" "github.com/pkg/errors" ) @@ -786,7 +786,7 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) { } srcFs := srcObj.fs key := f.root + remote - source := url.QueryEscape(srcFs.bucket + "/" + srcFs.root + srcObj.remote) + source := rest.URLEscape(srcFs.bucket + "/" + srcFs.root + srcObj.remote) req := s3.CopyObjectInput{ Bucket: &f.bucket, Key: &key, @@ -935,7 +935,7 @@ func (o *Object) SetModTime(modTime time.Time) error { ACL: &o.fs.acl, Key: &key, ContentType: &mimeType, - CopySource: aws.String(url.QueryEscape(sourceKey)), + CopySource: aws.String(rest.URLEscape(sourceKey)), Metadata: o.meta, MetadataDirective: &directive, }