diff options
Diffstat (limited to 'weed/s3api/s3api_object_handlers.go')
| -rw-r--r-- | weed/s3api/s3api_object_handlers.go | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 77863acfe..bfaeb568b 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -198,9 +198,33 @@ func newListEntry(entry *filer_pb.Entry, key string, dir string, name string, bu StorageClass: StorageClass(storageClass), } if fetchOwner { + // Extract owner from S3 metadata (Extended attributes) instead of file system attributes + var ownerID, displayName string + if entry.Extended != nil { + if ownerBytes, exists := entry.Extended[s3_constants.ExtAmzOwnerKey]; exists { + ownerID = string(ownerBytes) + } + } + + // Fallback to anonymous if no S3 owner found + if ownerID == "" { + ownerID = s3_constants.AccountAnonymousId + displayName = "anonymous" + } else { + // Try to resolve display name from IAM system + displayName = "unknown" + // Note: IAM resolution would require access to the S3ApiServer instance + // For now, use a simple fallback or could be enhanced later + } + + // Additional fallback to file system username if available and no display name resolved + if displayName == "unknown" && entry.Attributes.UserName != "" { + displayName = entry.Attributes.UserName + } + listEntry.Owner = CanonicalUser{ - ID: fmt.Sprintf("%x", entry.Attributes.Uid), - DisplayName: entry.Attributes.UserName, + ID: ownerID, + DisplayName: displayName, } } return listEntry |
