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
This commit is contained in:
Jochen Munz 2020-12-24 11:13:42 +01:00 committed by GitHub
parent 187a5b1908
commit 5b1d8666b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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),