Browse Source

s3 api: fix listbucket common_prefixes issue

Signed-off-by: Lei Liu <lei01.liu@horizon.ai>
pull/1077/head
Lei Liu 5 years ago
parent
commit
2cb348a2c2
  1. 5
      weed/s3api/filer_multipart.go
  2. 8
      weed/s3api/s3api_objects_list_handlers.go
  3. 2
      weed/s3api/s3api_xsd_generated.go

5
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 {

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

2
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 {

Loading…
Cancel
Save