SelectObjectContentHandler - GET Object?select ---------- This implementation of the GET operation retrieves object content based on an SQL expression. In the request, along with the sql expression, you must also specify a data serialization format (JSON, CSV) of the object.
(w http.ResponseWriter, r *http.Request)
| 101 | // on an SQL expression. In the request, along with the sql expression, you must |
| 102 | // also specify a data serialization format (JSON, CSV) of the object. |
| 103 | func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r *http.Request) { |
| 104 | ctx := newContext(r, w, "SelectObject") |
| 105 | |
| 106 | defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r)) |
| 107 | |
| 108 | // Fetch object stat info. |
| 109 | objectAPI := api.ObjectAPI() |
| 110 | if objectAPI == nil { |
| 111 | writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL) |
| 112 | return |
| 113 | } |
| 114 | |
| 115 | if crypto.S3.IsRequested(r.Header) || crypto.S3KMS.IsRequested(r.Header) { // If SSE-S3 or SSE-KMS present -> AWS fails with undefined error |
| 116 | writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrBadRequest), r.URL) |
| 117 | return |
| 118 | } |
| 119 | |
| 120 | vars := mux.Vars(r) |
| 121 | bucket := vars["bucket"] |
| 122 | object, err := unescapePath(vars["object"]) |
| 123 | if err != nil { |
| 124 | writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) |
| 125 | return |
| 126 | } |
| 127 | |
| 128 | opts, err := getOpts(ctx, r, bucket, object) |
| 129 | if err != nil { |
| 130 | writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | getObjectInfo := objectAPI.GetObjectInfo |
| 135 | if api.CacheAPI() != nil { |
| 136 | getObjectInfo = api.CacheAPI().GetObjectInfo |
| 137 | } |
| 138 | |
| 139 | // Check for auth type to return S3 compatible error. |
| 140 | // type to return the correct error (NoSuchKey vs AccessDenied) |
| 141 | if s3Error := checkRequestAuthType(ctx, r, policy.GetObjectAction, bucket, object); s3Error != ErrNone { |
| 142 | if getRequestAuthType(r) == authTypeAnonymous { |
| 143 | // As per "Permission" section in |
| 144 | // https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html |
| 145 | // If the object you request does not exist, |
| 146 | // the error Amazon S3 returns depends on |
| 147 | // whether you also have the s3:ListBucket |
| 148 | // permission. |
| 149 | // * If you have the s3:ListBucket permission |
| 150 | // on the bucket, Amazon S3 will return an |
| 151 | // HTTP status code 404 ("no such key") |
| 152 | // error. |
| 153 | // * if you don’t have the s3:ListBucket |
| 154 | // permission, Amazon S3 will return an HTTP |
| 155 | // status code 403 ("access denied") error.` |
| 156 | if globalPolicySys.IsAllowed(policy.Args{ |
| 157 | Action: policy.ListBucketAction, |
| 158 | BucketName: bucket, |
| 159 | ConditionValues: getConditionValues(r, "", auth.AnonymousCredentials), |
| 160 | IsOwner: false, |
nothing calls this directly
no test coverage detected