MCPcopy
hub / github.com/cubefs/cubefs / uploadPartHandler

Method uploadPartHandler

objectnode/api_handler_multipart.go:154–274  ·  view source on GitHub ↗

Upload part Uploads a part in a multipart upload. API reference: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html .

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

152// Uploads a part in a multipart upload.
153// API reference: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html .
154func (o *ObjectNode) uploadPartHandler(w http.ResponseWriter, r *http.Request) {
155 var (
156 err error
157 errorCode *ErrorCode
158 )
159
160 span := trace.SpanFromContextSafe(r.Context())
161 defer func() {
162 o.errorResponse(w, r, err, errorCode)
163 }()
164
165 // check args
166 param := ParseRequestParam(r)
167 // get upload id and part number
168 uploadId := param.GetVar(ParamUploadId)
169 partNumber := param.GetVar(ParamPartNumber)
170 if uploadId == "" || partNumber == "" {
171 log.LogErrorf("uploadPartHandler: illegal uploadID or partNumber, requestID(%v)", GetRequestID(r))
172 errorCode = InvalidArgument
173 return
174 }
175
176 var partNumberInt uint16
177 if partNumberInt, err = safeConvertStrToUint16(partNumber); err != nil {
178 log.LogErrorf("uploadPartHandler: parse part number fail, requestID(%v) raw(%v) err(%v)",
179 GetRequestID(r), partNumber, err)
180 errorCode = InvalidPartNumber
181 return
182 }
183 if partNumberInt < uint16(MinPartNumberValid) || partNumberInt > uint16(MaxPartNumberValid) {
184 errorCode = InvalidPartNumber
185 return
186 }
187
188 if param.Bucket() == "" {
189 errorCode = InvalidBucketName
190 return
191 }
192 if param.Object() == "" {
193 errorCode = InvalidKey
194 return
195 }
196
197 // Get request MD5, if request MD5 is not empty, compute and verify it.
198 requestMD5 := r.Header.Get(ContentMD5)
199 if requestMD5 != "" {
200 decoded, err := base64.StdEncoding.DecodeString(requestMD5)
201 if err != nil {
202 errorCode = InvalidDigest
203 return
204 }
205 requestMD5 = hex.EncodeToString(decoded)
206 }
207
208 // Verify ContentLength
209 length := GetContentLength(r)
210 if length > SinglePutLimit {
211 errorCode = EntityTooLarge

Callers

nothing calls this directly

Calls 15

errorResponseMethod · 0.95
getVolMethod · 0.95
AcquireRateLimiterMethod · 0.95
WritePartMethod · 0.95
NameMethod · 0.95
SpanFromContextSafeFunction · 0.92
LogErrorfFunction · 0.92
ParseRequestParamFunction · 0.85
GetRequestIDFunction · 0.85
safeConvertStrToUint16Function · 0.85
GetContentLengthFunction · 0.85
handleWritePartErrFunction · 0.85

Tested by

no test coverage detected