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

Method GetObject

api-get-object.go:32–267  ·  view source on GitHub ↗

GetObject wrapper function that accepts a request context

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

Source from the content-addressed store, hash-verified

30
31// GetObject wrapper function that accepts a request context
32func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, opts GetObjectOptions) (*Object, error) {
33 // Input validation.
34 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
35 return nil, ErrorResponse{
36 StatusCode: http.StatusBadRequest,
37 Code: InvalidBucketName,
38 Message: err.Error(),
39 }
40 }
41 if err := s3utils.CheckValidObjectName(objectName); err != nil {
42 return nil, ErrorResponse{
43 StatusCode: http.StatusBadRequest,
44 Code: XMinioInvalidObjectName,
45 Message: err.Error(),
46 }
47 }
48
49 if opts.RDMABuffer != nil && c.rdmaEnabled {
50 n, err := c.getObjectRDMA(ctx, bucketName, objectName, opts)
51 if err != nil {
52 return nil, err
53 }
54 return &Object{
55 mutex: &sync.Mutex{},
56 isClosed: true,
57 objectInfo: ObjectInfo{
58 Key: objectName,
59 Size: n,
60 },
61 objectInfoSet: true,
62 }, nil
63 }
64
65 gctx, cancel := context.WithCancel(ctx)
66
67 // Detect if snowball is server location we are talking to.
68 var snowball bool
69 if location, ok := c.bucketLocCache.Get(bucketName); ok {
70 snowball = location == "snowball"
71 }
72
73 var (
74 err error
75 httpReader io.ReadCloser
76 objectInfo ObjectInfo
77 totalRead int
78 )
79
80 // Create request channel.
81 reqCh := make(chan getRequest)
82 // Create response channel.
83 resCh := make(chan getResponse)
84
85 // This routine feeds partial object data as and when the caller reads.
86 go func() {
87 defer close(resCh)
88 defer func() {
89 // Close the http response body before returning.

Calls 11

getObjectRDMAMethod · 0.95
getObjectMethod · 0.95
StatObjectMethod · 0.95
CheckValidBucketNameFunction · 0.92
CheckValidObjectNameFunction · 0.92
newObjectFunction · 0.85
SetRangeMethod · 0.80
ErrorMethod · 0.45
GetMethod · 0.45
CloseMethod · 0.45
SetMatchETagMethod · 0.45

Tested by

no test coverage detected