forked from TrueCloudLab/frostfs-s3-gw
[#146] Move getting chunk payload reader to separate function
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
e58ea40463
commit
751a9be7cc
2 changed files with 38 additions and 46 deletions
|
@ -217,6 +217,12 @@ func (h *handler) UploadPartHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
body, err := h.getBodyReader(r)
|
||||
if err != nil {
|
||||
h.logAndSendError(w, "failed to get body reader", reqInfo, err)
|
||||
return
|
||||
}
|
||||
|
||||
var size uint64
|
||||
if r.ContentLength > 0 {
|
||||
size = uint64(r.ContentLength)
|
||||
|
@ -230,28 +236,7 @@ func (h *handler) UploadPartHandler(w http.ResponseWriter, r *http.Request) {
|
|||
},
|
||||
PartNumber: partNumber,
|
||||
Size: size,
|
||||
Reader: r.Body,
|
||||
}
|
||||
|
||||
if api.IsSignedStreamingV4(r) {
|
||||
if decodeContentSize := r.Header.Get(api.AmzDecodedContentLength); len(decodeContentSize) > 0 {
|
||||
_, err := strconv.Atoi(decodeContentSize)
|
||||
if err != nil {
|
||||
h.logAndSendError(w, "cannot parse decode content length information", reqInfo,
|
||||
errors.GetAPIError(errors.ErrMissingContentLength))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
h.logAndSendError(w, "expecting decode content length information", reqInfo,
|
||||
errors.GetAPIError(errors.ErrMissingContentLength))
|
||||
return
|
||||
}
|
||||
chunkReader, err := newSignV4ChunkedReader(r)
|
||||
if err != nil {
|
||||
h.logAndSendError(w, "cannot initialize chunk reader", reqInfo, err)
|
||||
return
|
||||
}
|
||||
p.Reader = chunkReader
|
||||
Reader: body,
|
||||
}
|
||||
|
||||
p.Info.Encryption, err = formEncryptionParams(r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue