diff options
| author | adasauce <60991921+adasauce@users.noreply.github.com> | 2024-03-22 11:03:34 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-22 07:03:34 -0700 |
| commit | 61f4e40ad9e8abe1c78026b47cd8fce4eb4bd6ea (patch) | |
| tree | 7fbd60bcacb76a3ab402e3a8abcd6aab8aad24be /weed/s3api | |
| parent | a5582cc9212b7293bd1ad9e377ee0310c2fdab48 (diff) | |
| download | seaweedfs-61f4e40ad9e8abe1c78026b47cd8fce4eb4bd6ea.tar.xz seaweedfs-61f4e40ad9e8abe1c78026b47cd8fce4eb4bd6ea.zip | |
fix s3api: delimeter properly takes prefixes into account (#5411)
Diffstat (limited to 'weed/s3api')
| -rw-r--r-- | weed/s3api/s3api_objects_list_handlers.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/weed/s3api/s3api_objects_list_handlers.go b/weed/s3api/s3api_objects_list_handlers.go index b2ad915b9..f332da856 100644 --- a/weed/s3api/s3api_objects_list_handlers.go +++ b/weed/s3api/s3api_objects_list_handlers.go @@ -167,12 +167,16 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m 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 { + undelimitedPath := fmt.Sprintf("%s/%s", dir, entry.Name)[len(bucketPrefix):] + + // take into account a prefix if supplied while delimiting. + undelimitedPath = strings.TrimPrefix(undelimitedPath, originalPrefix) - // S3 clients expect the delimited prefix to contain the delimiter. - delimitedPrefix := delimitedPath[0] + delimiter + delimitedPath := strings.SplitN(undelimitedPath, delimiter, 2) + + if len(delimitedPath) == 2 { + // S3 clients expect the delimited prefix to contain the delimiter and prefix. + delimitedPrefix := originalPrefix + delimitedPath[0] + delimiter for i := range commonPrefixes { if commonPrefixes[i].Prefix == delimitedPrefix { |
