"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
swift: Fix uploading of chunked files with non ascii characters - fixes #350
Nick Craig-Woode6f340d2454a
diff --git a/swift/swift.go b/swift/swift.goindex ab317b852..17ea0359a 100644--- a/swift/swift.go+++ b/swift/swift.go@@ -618,6 +618,23 @@ func (o *Object) removeSegments(except string) error {return nil}+// urlEncode encodes a string so that it is a valid URL+//+// We don't use any of Go's standard methods as we need `/` not+// encoded but we need '&' encoded.+func urlEncode(str string) string {+ var buf bytes.Buffer+ for i := 0; i < len(str); i++ {+ c := str[i]+ if (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '/' || c == '.' {+ _ = buf.WriteByte(c)+ } else {+ _, _ = buf.WriteString(fmt.Sprintf("%%%02X", c))+ }+ }+ return buf.String()+}+// updateChunks updates the existing object using chunks to a separate// container. It returns a string which prefixes current segments.func (o *Object) updateChunks(in io.Reader, headers swift.Headers, size int64) (string, error) {@@ -645,7 +662,7 @@ func (o *Object) updateChunks(in io.Reader, headers swift.Headers, size int64) (i++}// Upload the manifest- headers["X-Object-Manifest"] = fmt.Sprintf("%s/%s", o.fs.segmentsContainer, segmentsPath)+ headers["X-Object-Manifest"] = urlEncode(fmt.Sprintf("%s/%s", o.fs.segmentsContainer, segmentsPath))headers["Content-Length"] = "0" // set Content-Length as we know itemptyReader := bytes.NewReader(nil)manifestName := o.fs.root + o.remote