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

Method GetObjectAttributes

api-get-object-attributes.go:221–287  ·  view source on GitHub ↗

GetObjectAttributes API combines HeadObject and ListParts. More details on usage can be found in the documentation for ObjectAttributesOptions{}

(ctx context.Context, bucketName, objectName string, opts ObjectAttributesOptions)

Source from the content-addressed store, hash-verified

219// GetObjectAttributes API combines HeadObject and ListParts.
220// More details on usage can be found in the documentation for ObjectAttributesOptions{}
221func (c *Client) GetObjectAttributes(ctx context.Context, bucketName, objectName string, opts ObjectAttributesOptions) (*ObjectAttributes, error) {
222 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
223 return nil, err
224 }
225
226 if err := s3utils.CheckValidObjectName(objectName); err != nil {
227 return nil, err
228 }
229
230 urlValues := make(url.Values)
231 urlValues.Add("attributes", "")
232 if opts.VersionID != "" {
233 urlValues.Add("versionId", opts.VersionID)
234 }
235
236 headers := make(http.Header)
237 headers.Set(amzObjectAttributes, GetObjectAttributesTags)
238
239 if opts.PartNumberMarker > 0 {
240 headers.Set(amzPartNumberMarker, strconv.Itoa(opts.PartNumberMarker))
241 }
242
243 if opts.MaxParts > 0 {
244 headers.Set(amzMaxParts, strconv.Itoa(opts.MaxParts))
245 } else {
246 headers.Set(amzMaxParts, strconv.Itoa(GetObjectAttributesMaxParts))
247 }
248
249 if opts.ServerSideEncryption != nil {
250 opts.ServerSideEncryption.Marshal(headers)
251 }
252
253 resp, err := c.executeMethod(ctx, http.MethodGet, requestMetadata{
254 bucketName: bucketName,
255 objectName: objectName,
256 queryValues: urlValues,
257 contentSHA256Hex: emptySHA256Hex,
258 customHeader: headers,
259 })
260 if err != nil {
261 return nil, err
262 }
263
264 defer closeResponse(resp)
265
266 hasEtag := resp.Header.Get(ETag)
267 if hasEtag != "" {
268 return nil, errors.New("getObjectAttributes is not supported by the current endpoint version")
269 }
270
271 if resp.StatusCode != http.StatusOK {
272 ER := new(ErrorResponse)
273 if err := xml.NewDecoder(resp.Body).Decode(ER); err != nil {
274 return nil, err
275 }
276
277 return nil, *ER
278 }

Calls 9

executeMethodMethod · 0.95
CheckValidBucketNameFunction · 0.92
CheckValidObjectNameFunction · 0.92
parseResponseMethod · 0.80
closeResponseFunction · 0.70
MarshalMethod · 0.65
AddMethod · 0.45
SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected