MCPcopy
hub / github.com/minio/minio-go / GetObjectACL

Method GetObjectACL

api-get-object-acl.go:56–101  ·  view source on GitHub ↗

GetObjectACL get object ACLs

(ctx context.Context, bucketName, objectName string)

Source from the content-addressed store, hash-verified

54
55// GetObjectACL get object ACLs
56func (c *Client) GetObjectACL(ctx context.Context, bucketName, objectName string) (*ObjectInfo, error) {
57 resp, err := c.executeMethod(ctx, http.MethodGet, requestMetadata{
58 bucketName: bucketName,
59 objectName: objectName,
60 queryValues: url.Values{
61 "acl": []string{""},
62 },
63 })
64 if err != nil {
65 return nil, err
66 }
67 defer closeResponse(resp)
68
69 if resp.StatusCode != http.StatusOK {
70 return nil, httpRespToErrorResponse(resp, bucketName, objectName)
71 }
72
73 res := &accessControlPolicy{}
74
75 if err := xmlDecoder(resp.Body, res); err != nil {
76 return nil, err
77 }
78
79 objInfo, err := c.StatObject(ctx, bucketName, objectName, StatObjectOptions{})
80 if err != nil {
81 return nil, err
82 }
83
84 objInfo.Owner.DisplayName = res.Owner.DisplayName
85 objInfo.Owner.ID = res.Owner.ID
86
87 objInfo.Grant = append(objInfo.Grant, res.AccessControlList.Grant...)
88
89 cannedACL := getCannedACL(res)
90 if cannedACL != "" {
91 objInfo.Metadata.Add("X-Amz-Acl", cannedACL)
92 return &objInfo, nil
93 }
94
95 grantACL := getAmzGrantACL(res)
96 for k, v := range grantACL {
97 objInfo.Metadata[k] = v
98 }
99
100 return &objInfo, nil
101}
102
103func getCannedACL(aCPolicy *accessControlPolicy) string {
104 grants := aCPolicy.AccessControlList.Grant

Callers 2

testGetObjectACLContextFunction · 0.95
mainFunction · 0.80

Calls 8

executeMethodMethod · 0.95
StatObjectMethod · 0.95
httpRespToErrorResponseFunction · 0.85
getCannedACLFunction · 0.85
getAmzGrantACLFunction · 0.85
closeResponseFunction · 0.70
xmlDecoderFunction · 0.70
AddMethod · 0.45

Tested by

no test coverage detected