From 2cb348a2c2d31775578d40024ffcf5123724e869 Mon Sep 17 00:00:00 2001 From: Lei Liu Date: Sun, 29 Sep 2019 21:05:37 +0800 Subject: [PATCH] s3 api: fix listbucket common_prefixes issue Signed-off-by: Lei Liu --- weed/s3api/filer_multipart.go | 5 +++++ weed/s3api/s3api_objects_list_handlers.go | 8 +++++--- weed/s3api/s3api_xsd_generated.go | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/weed/s3api/filer_multipart.go b/weed/s3api/filer_multipart.go index c8fe05645..3bf4aafac 100644 --- a/weed/s3api/filer_multipart.go +++ b/weed/s3api/filer_multipart.go @@ -91,6 +91,11 @@ func (s3a *S3ApiServer) completeMultipartUpload(ctx context.Context, input *s3.C } dirName = fmt.Sprintf("%s/%s/%s", s3a.option.BucketsPath, *input.Bucket, dirName) + // remove suffix '/' + if strings.HasSuffix(dirName, "/") { + dirName = dirName[:len(dirName)-1] + } + err = s3a.mkFile(ctx, dirName, entryName, finalParts) if err != nil { diff --git a/weed/s3api/s3api_objects_list_handlers.go b/weed/s3api/s3api_objects_list_handlers.go index 4053913fb..1fc8b6b37 100644 --- a/weed/s3api/s3api_objects_list_handlers.go +++ b/weed/s3api/s3api_objects_list_handlers.go @@ -125,9 +125,11 @@ func (s3a *S3ApiServer) listFilerEntries(ctx context.Context, bucket, originalPr } lastEntryName = entry.Name if entry.IsDirectory { - commonPrefixes = append(commonPrefixes, PrefixEntry{ - Prefix: fmt.Sprintf("%s%s/", dir, entry.Name), - }) + if entry.Name != ".uploads" { + commonPrefixes = append(commonPrefixes, PrefixEntry{ + Prefix: fmt.Sprintf("%s%s/", dir, entry.Name), + }) + } } else { contents = append(contents, ListEntry{ Key: fmt.Sprintf("%s%s", dir, entry.Name), diff --git a/weed/s3api/s3api_xsd_generated.go b/weed/s3api/s3api_xsd_generated.go index 573c09ede..9d62afc4e 100644 --- a/weed/s3api/s3api_xsd_generated.go +++ b/weed/s3api/s3api_xsd_generated.go @@ -675,7 +675,7 @@ type PostResponse struct { } type PrefixEntry struct { - Prefix string `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Prefix"` + Prefix string `xml:"Prefix"` } type PutObject struct {