From 5b1d8666b3815751f3309c0616e2eb7d320efa76 Mon Sep 17 00:00:00 2001 From: Jochen Munz Date: Thu, 24 Dec 2020 11:13:42 +0100 Subject: [PATCH] S3fs: Handle non-ascii filename in rename operations (#257) SFTP is based on UTF-8 filenames, so non-ASCII filenames get transported with utf-8 escaped character sequences. At least for the S3fs provider, if such a file is stored in a nested path it cannot be used as the source for a rename operations. This adds the necessary escaping of the path fragments. The patch is not required for MinIO but it doesn't hurt --- vfs/s3fs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vfs/s3fs.go b/vfs/s3fs.go index 1c9447ea..3e46e130 100644 --- a/vfs/s3fs.go +++ b/vfs/s3fs.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "mime" + "net/url" "os" "path" "path/filepath" @@ -297,7 +298,7 @@ func (fs *S3Fs) Rename(source, target string) error { defer cancelFn() _, err = fs.svc.CopyObjectWithContext(ctx, &s3.CopyObjectInput{ Bucket: aws.String(fs.config.Bucket), - CopySource: aws.String(copySource), + CopySource: aws.String(url.PathEscape(copySource)), Key: aws.String(target), StorageClass: utils.NilIfEmpty(fs.config.StorageClass), ContentType: utils.NilIfEmpty(contentType),