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)
| 439 | |
| 440 | // SelectObjectContent is a implementation of http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectSELECTContent.html AWS S3 API. |
| 441 | func (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. |
no test coverage detected