|
|
|
@ -238,8 +238,6 @@ func (api gatewayAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
|
// Make sure we hex encode md5sum here.
|
|
|
|
|
metadata["etag"] = hex.EncodeToString(md5Bytes) |
|
|
|
|
|
|
|
|
|
sha256sum := "" |
|
|
|
|
|
|
|
|
|
// Lock the object.
|
|
|
|
|
objectLock := globalNSMutex.NewNSLock(bucket, object) |
|
|
|
|
objectLock.Lock() |
|
|
|
@ -249,7 +247,7 @@ func (api gatewayAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
|
switch reqAuthType { |
|
|
|
|
case authTypeAnonymous: |
|
|
|
|
// Create anonymous object.
|
|
|
|
|
objInfo, err = objectAPI.AnonPutObject(bucket, object, size, r.Body, metadata, sha256sum) |
|
|
|
|
objInfo, err = objectAPI.AnonPutObject(bucket, object, size, r.Body, metadata, "") |
|
|
|
|
case authTypeStreamingSigned: |
|
|
|
|
// Initialize stream signature verifier.
|
|
|
|
|
reader, s3Error := newSignV4ChunkedReader(r) |
|
|
|
@ -258,7 +256,7 @@ func (api gatewayAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
|
writeErrorResponse(w, s3Error, r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
objInfo, err = objectAPI.PutObject(bucket, object, size, reader, metadata, sha256sum) |
|
|
|
|
objInfo, err = objectAPI.PutObject(bucket, object, size, reader, metadata, "") |
|
|
|
|
case authTypeSignedV2, authTypePresignedV2: |
|
|
|
|
s3Error := isReqAuthenticatedV2(r) |
|
|
|
|
if s3Error != ErrNone { |
|
|
|
@ -266,16 +264,20 @@ func (api gatewayAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
|
writeErrorResponse(w, s3Error, r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
objInfo, err = objectAPI.PutObject(bucket, object, size, r.Body, metadata, sha256sum) |
|
|
|
|
objInfo, err = objectAPI.PutObject(bucket, object, size, r.Body, metadata, "") |
|
|
|
|
case authTypePresigned, authTypeSigned: |
|
|
|
|
if s3Error := reqSignatureV4Verify(r, serverConfig.GetRegion()); s3Error != ErrNone { |
|
|
|
|
errorIf(errSignatureMismatch, "%s", dumpRequest(r)) |
|
|
|
|
writeErrorResponse(w, s3Error, r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sha256sum := getContentSha256Cksum(r) |
|
|
|
|
|
|
|
|
|
if !skipContentSha256Cksum(r) { |
|
|
|
|
sha256sum = r.Header.Get("X-Amz-Content-Sha256") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Create object.
|
|
|
|
|
objInfo, err = objectAPI.PutObject(bucket, object, size, r.Body, metadata, sha256sum) |
|
|
|
|
default: |
|
|
|
|