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

Method SelectObjectContent

api-select.go:441–475  ·  view source on GitHub ↗

SelectObjectContent is a implementation of http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectSELECTContent.html AWS S3 API.

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

Source from the content-addressed store, hash-verified

439
440// SelectObjectContent is a implementation of http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectSELECTContent.html AWS S3 API.
441func (c *Client) SelectObjectContent(ctx context.Context, bucketName, objectName string, opts SelectObjectOptions) (*SelectResults, error) {
442 // Input validation.
443 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
444 return nil, err
445 }
446 if err := s3utils.CheckValidObjectName(objectName); err != nil {
447 return nil, err
448 }
449
450 selectReqBytes, err := xml.Marshal(opts)
451 if err != nil {
452 return nil, err
453 }
454
455 urlValues := make(url.Values)
456 urlValues.Set("select", "")
457 urlValues.Set("select-type", "2")
458
459 // Execute POST on bucket/object.
460 resp, err := c.executeMethod(ctx, http.MethodPost, requestMetadata{
461 bucketName: bucketName,
462 objectName: objectName,
463 queryValues: urlValues,
464 customHeader: opts.Header(),
465 contentMD5Base64: sumMD5Base64(selectReqBytes),
466 contentSHA256Hex: sum256Hex(selectReqBytes),
467 contentBody: bytes.NewReader(selectReqBytes),
468 contentLength: int64(len(selectReqBytes)),
469 })
470 if err != nil {
471 return nil, err
472 }
473
474 return NewSelectResults(resp, bucketName)
475}
476
477// NewSelectResults creates a Select Result parser that parses the response
478// and returns a Reader that will return parsed and assembled select output.

Callers 1

mainFunction · 0.80

Calls 9

executeMethodMethod · 0.95
CheckValidBucketNameFunction · 0.92
CheckValidObjectNameFunction · 0.92
sumMD5Base64Function · 0.85
sum256HexFunction · 0.85
NewSelectResultsFunction · 0.85
MarshalMethod · 0.65
SetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected