|
@ -47,10 +47,6 @@ func (s3a *S3ApiServer) ListObjectsV2Handler(w http.ResponseWriter, r *http.Requ |
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrInvalidMaxKeys) |
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrInvalidMaxKeys) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if delimiter != "" && delimiter != "/" { |
|
|
|
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrNotImplemented) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
marker := continuationToken |
|
|
marker := continuationToken |
|
|
if continuationToken == "" { |
|
|
if continuationToken == "" { |
|
@ -103,10 +99,6 @@ func (s3a *S3ApiServer) ListObjectsV1Handler(w http.ResponseWriter, r *http.Requ |
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrInvalidMaxKeys) |
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrInvalidMaxKeys) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if delimiter != "" && delimiter != "/" { |
|
|
|
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrNotImplemented) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
response, err := s3a.listFilerEntries(bucket, originalPrefix, maxKeys, marker, delimiter) |
|
|
response, err := s3a.listFilerEntries(bucket, originalPrefix, maxKeys, marker, delimiter) |
|
|
|
|
|
|
|
@ -171,6 +163,34 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m |
|
|
cursor.maxKeys-- |
|
|
cursor.maxKeys-- |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
var delimiterFound bool |
|
|
|
|
|
if delimiter != "" { |
|
|
|
|
|
// keys that contain the same string between the prefix and the first occurrence of the delimiter are grouped together as a commonPrefix.
|
|
|
|
|
|
// extract the string between the prefix and the delimiter and add it to the commonPrefixes if it's unique.
|
|
|
|
|
|
fullPath := fmt.Sprintf("%s/%s", dir, entry.Name)[len(bucketPrefix):] |
|
|
|
|
|
delimitedPath := strings.SplitN(fullPath, delimiter, 2) |
|
|
|
|
|
if len(delimitedPath) == 2 { |
|
|
|
|
|
|
|
|
|
|
|
// S3 clients expect the delimited prefix to contain the delimiter.
|
|
|
|
|
|
delimitedPrefix := delimitedPath[0] + delimiter |
|
|
|
|
|
|
|
|
|
|
|
for i := range commonPrefixes { |
|
|
|
|
|
if commonPrefixes[i].Prefix == delimitedPrefix { |
|
|
|
|
|
delimiterFound = true |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !delimiterFound { |
|
|
|
|
|
commonPrefixes = append(commonPrefixes, PrefixEntry{ |
|
|
|
|
|
Prefix: delimitedPrefix, |
|
|
|
|
|
}) |
|
|
|
|
|
cursor.maxKeys-- |
|
|
|
|
|
delimiterFound = true |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if !delimiterFound { |
|
|
storageClass := "STANDARD" |
|
|
storageClass := "STANDARD" |
|
|
if v, ok := entry.Extended[s3_constants.AmzStorageClass]; ok { |
|
|
if v, ok := entry.Extended[s3_constants.AmzStorageClass]; ok { |
|
|
storageClass = string(v) |
|
|
storageClass = string(v) |
|
@ -188,6 +208,7 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m |
|
|
}) |
|
|
}) |
|
|
cursor.maxKeys-- |
|
|
cursor.maxKeys-- |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
if doErr != nil { |
|
|
if doErr != nil { |
|
|
return doErr |
|
|
return doErr |
|
|