forked from TrueCloudLab/frostfs-s3-gw
[#159] Add fetch-owner param
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
642f8cc3eb
commit
65a61a9f7d
3 changed files with 18 additions and 9 deletions
|
@ -44,7 +44,7 @@ func encodeV1(p *layer.ListObjectsParamsV1, list *layer.ListObjectsInfoV1) *List
|
|||
|
||||
res.CommonPrefixes = fillPrefixes(list.Prefixes, p.Encode)
|
||||
|
||||
res.Contents = fillContents(list.Objects, p.Encode)
|
||||
res.Contents = fillContentsWithOwner(list.Objects, p.Encode)
|
||||
|
||||
return res
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ func encodeV2(p *layer.ListObjectsParamsV2, list *layer.ListObjectsInfoV2) *List
|
|||
|
||||
res.CommonPrefixes = fillPrefixes(list.Prefixes, p.Encode)
|
||||
|
||||
res.Contents = fillContents(list.Objects, p.Encode)
|
||||
res.Contents = fillContents(list.Objects, p.Encode, p.FetchOwner)
|
||||
|
||||
return res
|
||||
}
|
||||
|
@ -123,6 +123,7 @@ func parseListObjectsArgsV2(r *http.Request) (*layer.ListObjectsParamsV2, error)
|
|||
|
||||
res.ContinuationToken = r.URL.Query().Get("continuation-token")
|
||||
res.StartAfter = r.URL.Query().Get("start-after")
|
||||
res.FetchOwner, _ = strconv.ParseBool(r.URL.Query().Get("fetch-owner"))
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
|
@ -160,21 +161,28 @@ func fillPrefixes(src []string, encode string) []CommonPrefix {
|
|||
return dst
|
||||
}
|
||||
|
||||
func fillContents(src []*layer.ObjectInfo, encode string) []Object {
|
||||
func fillContentsWithOwner(src []*layer.ObjectInfo, encode string) []Object {
|
||||
return fillContents(src, encode, true)
|
||||
}
|
||||
|
||||
func fillContents(src []*layer.ObjectInfo, encode string, fetchOwner bool) []Object {
|
||||
var dst []Object
|
||||
for _, obj := range src {
|
||||
dst = append(dst, Object{
|
||||
res := Object{
|
||||
Key: s3PathEncode(obj.Name, encode),
|
||||
Size: obj.Size,
|
||||
LastModified: obj.Created.Format(time.RFC3339),
|
||||
ETag: obj.HashSum,
|
||||
}
|
||||
|
||||
Owner: Owner{
|
||||
if fetchOwner {
|
||||
res.Owner = &Owner{
|
||||
ID: obj.Owner.String(),
|
||||
DisplayName: obj.Owner.String(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
ETag: obj.HashSum,
|
||||
})
|
||||
dst = append(dst, res)
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ type Object struct {
|
|||
Size int64
|
||||
|
||||
// Owner of the object.
|
||||
Owner Owner
|
||||
Owner *Owner `xml:"Owner,omitempty"`
|
||||
|
||||
// The class of storage used to store the object.
|
||||
StorageClass string `xml:"StorageClass,omitempty"`
|
||||
|
|
|
@ -53,6 +53,7 @@ type (
|
|||
ListObjectsParamsCommon
|
||||
ContinuationToken string
|
||||
StartAfter string
|
||||
FetchOwner bool
|
||||
}
|
||||
|
||||
allObjectParams struct {
|
||||
|
|
Loading…
Reference in a new issue