s3: URL escape CopySource

This fixes metadata update and copy for files with `+` in

Fixes #315
This commit is contained in:
Nick Craig-Wood 2016-01-27 17:39:33 +00:00
parent 8c211fc8df
commit cae19df058

View file

@ -17,6 +17,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"net/url"
"path" "path"
"regexp" "regexp"
"strings" "strings"
@ -523,7 +524,7 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) {
} }
srcFs := srcObj.fs srcFs := srcObj.fs
key := f.root + remote key := f.root + remote
source := srcFs.bucket + "/" + srcFs.root + srcObj.remote source := url.QueryEscape(srcFs.bucket + "/" + srcFs.root + srcObj.remote)
req := s3.CopyObjectInput{ req := s3.CopyObjectInput{
Bucket: &f.bucket, Bucket: &f.bucket,
Key: &key, Key: &key,
@ -664,7 +665,7 @@ func (o *Object) SetModTime(modTime time.Time) {
ACL: &o.fs.perm, ACL: &o.fs.perm,
Key: &key, Key: &key,
ContentType: &contentType, ContentType: &contentType,
CopySource: &sourceKey, CopySource: aws.String(url.QueryEscape(sourceKey)),
Metadata: o.meta, Metadata: o.meta,
MetadataDirective: &directive, MetadataDirective: &directive,
} }