@ -124,7 +124,7 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r
}
}
_ , err := getObjectInfo ( ctx , bucket , object , ObjectOptions { } )
_ , err := getObjectInfo ( ctx , bucket , object , ObjectOptions { } )
if toAPIErrorCode ( err ) == ErrNoSuchKey {
if toAPIErrorCode ( ctx , err ) == ErrNoSuchKey {
s3Error = ErrNoSuchKey
s3Error = ErrNoSuchKey
}
}
}
}
@ -166,7 +166,7 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r
gr , err := getObjectNInfo ( ctx , bucket , object , nil , r . Header , readLock , ObjectOptions { } )
gr , err := getObjectNInfo ( ctx , bucket , object , nil , r . Header , readLock , ObjectOptions { } )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
defer gr . Close ( )
defer gr . Close ( )
@ -257,14 +257,14 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r
s3s , err := s3select . New ( reader , objInfo . GetActualSize ( ) , selectReq )
s3s , err := s3select . New ( reader , objInfo . GetActualSize ( ) , selectReq )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
// Parses the select query and checks for an error
// Parses the select query and checks for an error
_ , _ , _ , _ , _ , _ , err = s3select . ParseSelect ( s3s )
_ , _ , _ , _ , _ , _ , err = s3select . ParseSelect ( s3s )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -343,7 +343,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
}
}
_ , err := getObjectInfo ( ctx , bucket , object , opts )
_ , err := getObjectInfo ( ctx , bucket , object , opts )
if toAPIErrorCode ( err ) == ErrNoSuchKey {
if toAPIErrorCode ( ctx , err ) == ErrNoSuchKey {
s3Error = ErrNoSuchKey
s3Error = ErrNoSuchKey
}
}
}
}
@ -377,7 +377,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
gr , err := getObjectNInfo ( ctx , bucket , object , rs , r . Header , readLock , opts )
gr , err := getObjectNInfo ( ctx , bucket , object , rs , r . Header , readLock , opts )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
defer gr . Close ( )
defer gr . Close ( )
@ -386,7 +386,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
if objectAPI . IsEncryptionSupported ( ) {
if objectAPI . IsEncryptionSupported ( ) {
if _ , err = DecryptObjectInfo ( objInfo , r . Header ) ; err != nil {
if _ , err = DecryptObjectInfo ( objInfo , r . Header ) ; err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -409,8 +409,8 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
}
}
}
}
if hErr : = setObjectHeaders ( w , objInfo , rs ) ; hE rr != nil {
if err = setObjectHeaders ( w , objInfo , rs ) ; e rr != nil {
writeErrorResponse ( w , toAPIErrorCode ( hE rr) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , e rr) , r . URL )
return
return
}
}
@ -426,14 +426,14 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
// Write object content to response body
// Write object content to response body
if _ , err = io . Copy ( httpWriter , gr ) ; err != nil {
if _ , err = io . Copy ( httpWriter , gr ) ; err != nil {
if ! httpWriter . HasWritten ( ) && ! statusCodeWritten { // write error response only if no data or headers has been written to client yet
if ! httpWriter . HasWritten ( ) && ! statusCodeWritten { // write error response only if no data or headers has been written to client yet
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
}
}
return
return
}
}
if err = httpWriter . Close ( ) ; err != nil {
if err = httpWriter . Close ( ) ; err != nil {
if ! httpWriter . HasWritten ( ) && ! statusCodeWritten { // write error response only if no data or headers has been written to client yet
if ! httpWriter . HasWritten ( ) && ! statusCodeWritten { // write error response only if no data or headers has been written to client yet
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -507,7 +507,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
IsOwner : false ,
IsOwner : false ,
} ) {
} ) {
_ , err := getObjectInfo ( ctx , bucket , object , opts )
_ , err := getObjectInfo ( ctx , bucket , object , opts )
if toAPIErrorCode ( err ) == ErrNoSuchKey {
if toAPIErrorCode ( ctx , err ) == ErrNoSuchKey {
s3Error = ErrNoSuchKey
s3Error = ErrNoSuchKey
}
}
}
}
@ -536,13 +536,13 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
objInfo , err := getObjectInfo ( ctx , bucket , object , opts )
objInfo , err := getObjectInfo ( ctx , bucket , object , opts )
if err != nil {
if err != nil {
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( err ) )
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( ctx , err ) )
return
return
}
}
if objectAPI . IsEncryptionSupported ( ) {
if objectAPI . IsEncryptionSupported ( ) {
if _ , err = DecryptObjectInfo ( objInfo , r . Header ) ; err != nil {
if _ , err = DecryptObjectInfo ( objInfo , r . Header ) ; err != nil {
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( err ) )
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( ctx , err ) )
return
return
}
}
}
}
@ -556,7 +556,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
case crypto . SSEC . IsEncrypted ( objInfo . UserDefined ) :
case crypto . SSEC . IsEncrypted ( objInfo . UserDefined ) :
// Validate the SSE-C Key set in the header.
// Validate the SSE-C Key set in the header.
if _ , err = crypto . SSEC . UnsealObjectKey ( r . Header , objInfo . UserDefined , bucket , object ) ; err != nil {
if _ , err = crypto . SSEC . UnsealObjectKey ( r . Header , objInfo . UserDefined , bucket , object ) ; err != nil {
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( err ) )
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( ctx , err ) )
return
return
}
}
w . Header ( ) . Set ( crypto . SSECAlgorithm , r . Header . Get ( crypto . SSECAlgorithm ) )
w . Header ( ) . Set ( crypto . SSECAlgorithm , r . Header . Get ( crypto . SSECAlgorithm ) )
@ -571,8 +571,8 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
}
}
// Set standard object headers.
// Set standard object headers.
if hErr : = setObjectHeaders ( w , objInfo , rs ) ; hE rr != nil {
if err = setObjectHeaders ( w , objInfo , rs ) ; e rr != nil {
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( hE rr) )
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( ctx , e rr) )
return
return
}
}
@ -716,7 +716,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
var rs * HTTPRangeSpec
var rs * HTTPRangeSpec
gr , err := getObjectNInfo ( ctx , srcBucket , srcObject , rs , r . Header , lock , srcOpts )
gr , err := getObjectNInfo ( ctx , srcBucket , srcObject , rs , r . Header , lock , srcOpts )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
defer gr . Close ( )
defer gr . Close ( )
@ -758,7 +758,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
if crypto . IsEncrypted ( srcInfo . UserDefined ) {
if crypto . IsEncrypted ( srcInfo . UserDefined ) {
actualSize , err = srcInfo . DecryptedSize ( )
actualSize , err = srcInfo . DecryptedSize ( )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -797,7 +797,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
srcInfo . Reader , err = hash . NewReader ( reader , length , "" , "" , actualSize )
srcInfo . Reader , err = hash . NewReader ( reader , length , "" , "" , actualSize )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -805,7 +805,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
if objectAPI . IsEncryptionSupported ( ) && ! isCompressed {
if objectAPI . IsEncryptionSupported ( ) && ! isCompressed {
// Encryption parameters not applicable for this object.
// Encryption parameters not applicable for this object.
if ! crypto . IsEncrypted ( srcInfo . UserDefined ) && crypto . SSECopy . IsRequested ( r . Header ) {
if ! crypto . IsEncrypted ( srcInfo . UserDefined ) && crypto . SSECopy . IsRequested ( r . Header ) {
writeErrorResponse ( w , toAPIErrorCode ( errInvalidEncryptionParameters ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , errInvalidEncryptionParameters ) , r . URL )
return
return
}
}
// Encryption parameters not present for this object.
// Encryption parameters not present for this object.
@ -825,7 +825,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
if sseC {
if sseC {
newKey , err = ParseSSECustomerRequest ( r )
newKey , err = ParseSSECustomerRequest ( r )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -838,7 +838,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
if sseCopyC && sseC {
if sseCopyC && sseC {
oldKey , err = ParseSSECopyCustomerRequest ( r . Header , srcInfo . UserDefined )
oldKey , err = ParseSSECopyCustomerRequest ( r . Header , srcInfo . UserDefined )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -848,7 +848,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
// In case of SSE-S3 oldKey and newKey aren't used - the KMS manages the keys.
// In case of SSE-S3 oldKey and newKey aren't used - the KMS manages the keys.
if err = rotateKey ( oldKey , newKey , srcBucket , srcObject , encMetadata ) ; err != nil {
if err = rotateKey ( oldKey , newKey , srcBucket , srcObject , encMetadata ) ; err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -880,7 +880,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
if isTargetEncrypted {
if isTargetEncrypted {
reader , err = newEncryptReader ( reader , newKey , dstBucket , dstObject , encMetadata , sseS3 )
reader , err = newEncryptReader ( reader , newKey , dstBucket , dstObject , encMetadata , sseS3 )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -893,7 +893,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
srcInfo . Reader , err = hash . NewReader ( reader , targetSize , "" , "" , targetSize ) // do not try to verify encrypted content
srcInfo . Reader , err = hash . NewReader ( reader , targetSize , "" , "" , targetSize ) // do not try to verify encrypted content
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -966,7 +966,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
// object is same then only metadata is updated.
// object is same then only metadata is updated.
objInfo , err = objectAPI . CopyObject ( ctx , srcBucket , srcObject , dstBucket , dstObject , srcInfo , srcOpts , dstOpts )
objInfo , err = objectAPI . CopyObject ( ctx , srcBucket , srcObject , dstBucket , dstObject , srcInfo , srcOpts , dstOpts )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -1059,7 +1059,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
}
}
size , err = strconv . ParseInt ( sizeStr [ 0 ] , 10 , 64 )
size , err = strconv . ParseInt ( sizeStr [ 0 ] , 10 , 64 )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -1154,7 +1154,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
var actualReader * hash . Reader
var actualReader * hash . Reader
actualReader , err = hash . NewReader ( reader , size , md5hex , sha256hex , actualSize )
actualReader , err = hash . NewReader ( reader , size , md5hex , sha256hex , actualSize )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1174,7 +1174,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
hashReader , err := hash . NewReader ( reader , size , md5hex , sha256hex , actualSize )
hashReader , err := hash . NewReader ( reader , size , md5hex , sha256hex , actualSize )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
opts := ObjectOptions { }
opts := ObjectOptions { }
@ -1190,13 +1190,13 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
if hasServerSideEncryptionHeader ( r . Header ) && ! hasSuffix ( object , slashSeparator ) { // handle SSE requests
if hasServerSideEncryptionHeader ( r . Header ) && ! hasSuffix ( object , slashSeparator ) { // handle SSE requests
reader , err = EncryptRequest ( hashReader , r , bucket , object , metadata )
reader , err = EncryptRequest ( hashReader , r , bucket , object , metadata )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
info := ObjectInfo { Size : size }
info := ObjectInfo { Size : size }
hashReader , err = hash . NewReader ( reader , info . EncryptedSize ( ) , "" , "" , size ) // do not try to verify encrypted content
hashReader , err = hash . NewReader ( reader , info . EncryptedSize ( ) , "" , "" , size ) // do not try to verify encrypted content
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -1212,7 +1212,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
// Create the object..
// Create the object..
objInfo , err := putObject ( ctx , bucket , object , hashReader , metadata , opts )
objInfo , err := putObject ( ctx , bucket , object , hashReader , metadata , opts )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1309,7 +1309,7 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r
if objectAPI . IsEncryptionSupported ( ) {
if objectAPI . IsEncryptionSupported ( ) {
if hasServerSideEncryptionHeader ( r . Header ) {
if hasServerSideEncryptionHeader ( r . Header ) {
if err := setEncryptionMetadata ( r , bucket , object , encMetadata ) ; err != nil {
if err := setEncryptionMetadata ( r , bucket , object , encMetadata ) ; err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
// Set this for multipart only operations, we need to differentiate during
// Set this for multipart only operations, we need to differentiate during
@ -1345,7 +1345,7 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r
}
}
uploadID , err := newMultipartUpload ( ctx , bucket , object , metadata , opts )
uploadID , err := newMultipartUpload ( ctx , bucket , object , metadata , opts )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1447,7 +1447,7 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
gr , err := getObjectNInfo ( ctx , srcBucket , srcObject , rs , r . Header , readLock , srcOpts )
gr , err := getObjectNInfo ( ctx , srcBucket , srcObject , rs , r . Header , readLock , srcOpts )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
defer gr . Close ( )
defer gr . Close ( )
@ -1457,7 +1457,7 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
if crypto . IsEncrypted ( srcInfo . UserDefined ) {
if crypto . IsEncrypted ( srcInfo . UserDefined ) {
actualPartSize , err = srcInfo . DecryptedSize ( )
actualPartSize , err = srcInfo . DecryptedSize ( )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -1476,7 +1476,7 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
// Get the object offset & length
// Get the object offset & length
startOffset , length , err := rs . GetOffsetLength ( actualPartSize )
startOffset , length , err := rs . GetOffsetLength ( actualPartSize )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1492,7 +1492,7 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
var li ListPartsInfo
var li ListPartsInfo
li , err = objectAPI . ListObjectParts ( ctx , dstBucket , dstObject , uploadID , 0 , 1 )
li , err = objectAPI . ListObjectParts ( ctx , dstBucket , dstObject , uploadID , 0 , 1 )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1522,7 +1522,7 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
srcInfo . Reader , err = hash . NewReader ( reader , length , "" , "" , actualPartSize )
srcInfo . Reader , err = hash . NewReader ( reader , length , "" , "" , actualPartSize )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1540,14 +1540,14 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
if crypto . SSEC . IsRequested ( r . Header ) {
if crypto . SSEC . IsRequested ( r . Header ) {
key , err = ParseSSECustomerRequest ( r )
key , err = ParseSSECustomerRequest ( r )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
var objectEncryptionKey [ ] byte
var objectEncryptionKey [ ] byte
objectEncryptionKey , err = decryptObjectInfo ( key , dstBucket , dstObject , li . UserDefined )
objectEncryptionKey , err = decryptObjectInfo ( key , dstBucket , dstObject , li . UserDefined )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1559,14 +1559,14 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
partEncryptionKey := mac . Sum ( nil )
partEncryptionKey := mac . Sum ( nil )
reader , err = sio . EncryptReader ( reader , sio . Config { Key : partEncryptionKey } )
reader , err = sio . EncryptReader ( reader , sio . Config { Key : partEncryptionKey } )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
info := ObjectInfo { Size : length }
info := ObjectInfo { Size : length }
srcInfo . Reader , err = hash . NewReader ( reader , info . EncryptedSize ( ) , "" , "" , length )
srcInfo . Reader , err = hash . NewReader ( reader , info . EncryptedSize ( ) , "" , "" , length )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -1577,7 +1577,7 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
partInfo , err := objectAPI . CopyObjectPart ( ctx , srcBucket , srcObject , dstBucket , dstObject , uploadID , partID ,
partInfo , err := objectAPI . CopyObjectPart ( ctx , srcBucket , srcObject , dstBucket , dstObject , uploadID , partID ,
startOffset , length , srcInfo , srcOpts , dstOpts )
startOffset , length , srcInfo , srcOpts , dstOpts )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1634,7 +1634,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
}
}
size , err = strconv . ParseInt ( sizeStr [ 0 ] , 10 , 64 )
size , err = strconv . ParseInt ( sizeStr [ 0 ] , 10 , 64 )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -1709,7 +1709,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
var li ListPartsInfo
var li ListPartsInfo
li , err = objectAPI . ListObjectParts ( ctx , bucket , object , uploadID , 0 , 1 )
li , err = objectAPI . ListObjectParts ( ctx , bucket , object , uploadID , 0 , 1 )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
// Read compression metadata preserved in the init multipart for the decision.
// Read compression metadata preserved in the init multipart for the decision.
@ -1723,7 +1723,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
var actualReader * hash . Reader
var actualReader * hash . Reader
actualReader , err = hash . NewReader ( reader , size , md5hex , sha256hex , actualSize )
actualReader , err = hash . NewReader ( reader , size , md5hex , sha256hex , actualSize )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1744,7 +1744,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
hashReader , err := hash . NewReader ( reader , size , md5hex , sha256hex , actualSize )
hashReader , err := hash . NewReader ( reader , size , md5hex , sha256hex , actualSize )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1762,7 +1762,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
var li ListPartsInfo
var li ListPartsInfo
li , err = objectAPI . ListObjectParts ( ctx , bucket , object , uploadID , 0 , 1 )
li , err = objectAPI . ListObjectParts ( ctx , bucket , object , uploadID , 0 , 1 )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
if crypto . IsEncrypted ( li . UserDefined ) {
if crypto . IsEncrypted ( li . UserDefined ) {
@ -1775,7 +1775,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
if crypto . SSEC . IsRequested ( r . Header ) {
if crypto . SSEC . IsRequested ( r . Header ) {
key , err = ParseSSECustomerRequest ( r )
key , err = ParseSSECustomerRequest ( r )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -1784,7 +1784,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
var objectEncryptionKey [ ] byte
var objectEncryptionKey [ ] byte
objectEncryptionKey , err = decryptObjectInfo ( key , bucket , object , li . UserDefined )
objectEncryptionKey , err = decryptObjectInfo ( key , bucket , object , li . UserDefined )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1797,14 +1797,14 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
reader , err = sio . EncryptReader ( hashReader , sio . Config { Key : partEncryptionKey } )
reader , err = sio . EncryptReader ( hashReader , sio . Config { Key : partEncryptionKey } )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
info := ObjectInfo { Size : size }
info := ObjectInfo { Size : size }
hashReader , err = hash . NewReader ( reader , info . EncryptedSize ( ) , "" , "" , size ) // do not try to verify encrypted content
hashReader , err = hash . NewReader ( reader , info . EncryptedSize ( ) , "" , "" , size ) // do not try to verify encrypted content
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
}
}
@ -1817,7 +1817,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
partInfo , err := putObjectPart ( ctx , bucket , object , uploadID , partID , hashReader , opts )
partInfo , err := putObjectPart ( ctx , bucket , object , uploadID , partID , hashReader , opts )
if err != nil {
if err != nil {
// Verify if the underlying error is signature mismatch.
// Verify if the underlying error is signature mismatch.
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
if isCompressed {
if isCompressed {
@ -1871,7 +1871,7 @@ func (api objectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter,
return
return
}
}
if err := abortMultipartUpload ( ctx , bucket , object , uploadID ) ; err != nil {
if err := abortMultipartUpload ( ctx , bucket , object , uploadID ) ; err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
@ -1914,7 +1914,7 @@ func (api objectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *ht
}
}
listPartsInfo , err := objectAPI . ListObjectParts ( ctx , bucket , object , uploadID , partNumberMarker , maxParts )
listPartsInfo , err := objectAPI . ListObjectParts ( ctx , bucket , object , uploadID , partNumberMarker , maxParts )
if err != nil {
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
return
return
}
}
response := generateListPartsResponse ( listPartsInfo )
response := generateListPartsResponse ( listPartsInfo )
@ -2003,7 +2003,7 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
writePartSmallErrorResponse ( w , r , oErr )
writePartSmallErrorResponse ( w , r , oErr )
default :
default :
// Handle all other generic issues.
// Handle all other generic issues.
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
}
}
return
return
}
}
@ -2080,7 +2080,7 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
if err == dns . ErrNoEntriesFound {
if err == dns . ErrNoEntriesFound {
writeErrorResponse ( w , ErrNoSuchBucket , r . URL )
writeErrorResponse ( w , ErrNoSuchBucket , r . URL )
} else {
} else {
writeErrorResponse ( w , toAPIErrorCode ( err ) , r . URL )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL )
}
}
return
return
}
}
@ -2088,7 +2088,7 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
// http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
// http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
if err := deleteObject ( ctx , objectAPI , api . CacheAPI ( ) , bucket , object , r ) ; err != nil {
if err := deleteObject ( ctx , objectAPI , api . CacheAPI ( ) , bucket , object , r ) ; err != nil {
switch toAPIErrorCode ( err ) {
switch toAPIErrorCode ( ctx , err ) {
case ErrNoSuchBucket :
case ErrNoSuchBucket :
// When bucket doesn't exist specially handle it.
// When bucket doesn't exist specially handle it.
writeErrorResponse ( w , ErrNoSuchBucket , r . URL )
writeErrorResponse ( w , ErrNoSuchBucket , r . URL )