@ -96,12 +96,12 @@ func (api objectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
writeErrorResponse ( w , ErrServerNotInitialized , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if s3Error := checkRequestAuthType ( ctx , r , policy . GetBucketLocationAction , bucket , "" ) ; s3Error != ErrNone {
writeErrorResponse ( w , s3Error , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -110,7 +110,7 @@ func (api objectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *
getBucketInfo = api . CacheAPI ( ) . GetBucketInfo
}
if _ , err := getBucketInfo ( ctx , bucket ) ; err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -146,35 +146,37 @@ func (api objectAPIHandlers) ListMultipartUploadsHandler(w http.ResponseWriter,
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
writeErrorResponse ( w , ErrServerNotInitialized , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if s3Error := checkRequestAuthType ( ctx , r , policy . ListBucketMultipartUploadsAction , bucket , "" ) ; s3Error != ErrNone {
writeErrorResponse ( w , s3Error , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
return
}
prefix , keyMarker , uploadIDMarker , delimiter , maxUploads , _ , s3Error := getBucketMultipartResources ( r . URL . Query ( ) )
if s3Error != ErrNone {
writeErrorResponse ( w , s3Error , r . URL , guessIsBrowserReq ( r ) )
prefix , keyMarker , uploadIDMarker , delimiter , maxUploads , _ , errCode := getBucketMultipartResources ( r . URL . Query ( ) )
if errCode != ErrNone {
writeErrorResponse ( w , errorCodes . ToAPIErr ( errCode ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if maxUploads < 0 {
writeErrorResponse ( w , ErrInvalidMaxUploads , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrInvalidMaxUploads ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if keyMarker != "" {
// Marker not common with prefix is not implemented.
if ! hasPrefix ( keyMarker , prefix ) {
writeErrorResponse ( w , ErrNotImplemented , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrNotImplemented ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}
listMultipartsInfo , err := objectAPI . ListMultipartUploads ( ctx , bucket , prefix , keyMarker , uploadIDMarker , delimiter , maxUploads )
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// generate response
@ -196,25 +198,26 @@ func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.R
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
writeErrorResponse ( w , ErrServerNotInitialized , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
return
}
listBuckets := objectAPI . ListBuckets
listBuckets := objectAPI . ListBuckets
if api . CacheAPI ( ) != nil {
listBuckets = api . CacheAPI ( ) . ListBuckets
}
if s3Error := checkRequestAuthType ( ctx , r , policy . ListAllMyBucketsAction , "" , "" ) ; s3Error != ErrNone {
writeErrorResponse ( w , s3Error , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// If etcd, dns federation configured list buckets from etcd.
var bucketsInfo [ ] BucketInfo
if globalDNSConfig != nil {
dnsBuckets , err := globalDNSConfig . List ( )
if err != nil && err != dns . ErrNoEntriesFound {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
bucketSet := set . NewStringSet ( )
@ -233,7 +236,7 @@ func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.R
var err error
bucketsInfo , err = listBuckets ( ctx )
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}
@ -257,7 +260,7 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
writeErrorResponse ( w , ErrServerNotInitialized , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -266,7 +269,7 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
// In the event access is denied, a 200 response should still be returned
// http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
if s3Error != ErrAccessDenied {
writeErrorResponse ( w , s3Error , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}
@ -274,14 +277,14 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
// Content-Length is required and should be non-zero
// http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
if r . ContentLength <= 0 {
writeErrorResponse ( w , ErrMissingContentLength , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMissingContentLength ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Content-Md5 is requied should be set
// http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
if _ , ok := r . Header [ "Content-Md5" ] ; ! ok {
writeErrorResponse ( w , ErrMissingContentMD5 , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMissingContentMD5 ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -297,7 +300,7 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
// Read incoming body XML bytes.
if _ , err := io . ReadFull ( r . Body , deleteXMLBytes ) ; err != nil {
logger . LogIf ( ctx , err )
writeErrorResponse ( w , ErrInternalError , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAdminAPIErr ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -305,7 +308,7 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
deleteObjects := & DeleteObjectsRequest { }
if err := xml . Unmarshal ( deleteXMLBytes , deleteObjects ) ; err != nil {
logger . LogIf ( ctx , err )
writeErrorResponse ( w , ErrMalformedXML , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMalformedXML ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -313,7 +316,7 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
if globalWORMEnabled {
// Not required to check whether given objects exist or not, because
// DeleteMultipleObject is always successful irrespective of object existence.
writeErrorResponse ( w , ErrMethodNotAllowed , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMethodNotAllowed ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -352,10 +355,11 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
deletedObjects = append ( deletedObjects , object )
continue
}
apiErr := toAPIError ( ctx , err )
// Error during delete should be collected separately.
deleteErrors = append ( deleteErrors , DeleteError {
Code : errorCodeResponse [ toAPIErrorCode ( ctx , err ) ] . Code ,
Message : errorCodeResponse [ toAPIErrorCode ( ctx , err ) ] . Description ,
Code : apiErr . Code ,
Message : apiErr . Description ,
Key : object . ObjectName ,
} )
}
@ -401,7 +405,7 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
writeErrorResponse ( w , ErrServerNotInitialized , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -409,21 +413,21 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req
bucket := vars [ "bucket" ]
if s3Error := checkRequestAuthType ( ctx , r , policy . CreateBucketAction , bucket , "" ) ; s3Error != ErrNone {
writeErrorResponse ( w , s3Error , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Parse incoming location constraint.
location , s3Error := parseLocationConstraint ( r )
if s3Error != ErrNone {
writeErrorResponse ( w , s3Error , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Validate if location sent by the client is valid, reject
// requests which do not follow valid region requirements.
if ! isValidLocation ( location ) {
writeErrorResponse ( w , ErrInvalidRegion , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrInvalidRegion ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -432,12 +436,12 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req
if err == dns . ErrNoEntriesFound {
// Proceed to creating a bucket.
if err = objectAPI . MakeBucketWithLocation ( ctx , bucket , location ) ; err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if err = globalDNSConfig . Put ( bucket ) ; err != nil {
objectAPI . DeleteBucket ( ctx , bucket )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -447,18 +451,18 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req
writeSuccessResponseHeadersOnly ( w )
return
}
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
writeErrorResponse ( w , ErrBucketAlreadyOwnedByYou , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrBucketAlreadyOwnedByYou ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Proceed to creating a bucket.
err := objectAPI . MakeBucketWithLocation ( ctx , bucket , location )
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -479,33 +483,36 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
writeErrorResponse ( w , ErrServerNotInitialized , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if crypto . S3KMS . IsRequested ( r . Header ) { // SSE-KMS is not supported
writeErrorResponse ( w , ErrNotImplemented , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrNotImplemented ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if ! api . EncryptionEnabled ( ) && hasServerSideEncryptionHeader ( r . Header ) {
writeErrorResponse ( w , ErrNotImplemented , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrNotImplemented ) , r . URL , guessIsBrowserReq ( r ) )
return
}
bucket := mux . Vars ( r ) [ "bucket" ]
// Require Content-Length to be set in the request
size := r . ContentLength
if size < 0 {
writeErrorResponse ( w , ErrMissingContentLength , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMissingContentLength ) , r . URL , guessIsBrowserReq ( r ) )
return
}
resource , err := getResource ( r . URL . Path , r . Host , globalDomainName )
if err != nil {
writeErrorResponse ( w , ErrInvalidRequest , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrInvalidRequest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Make sure that the URL does not contain object name.
if bucket != filepath . Clean ( resource [ 1 : ] ) {
writeErrorResponse ( w , ErrMethodNotAllowed , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMethodNotAllowed ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -514,7 +521,7 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
reader , err := r . MultipartReader ( )
if err != nil {
logger . LogIf ( ctx , err )
writeErrorResponse ( w , ErrMalformedPOSTRequest , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMalformedPOSTRequest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -522,7 +529,7 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
form , err := reader . ReadForm ( maxFormMemory )
if err != nil {
logger . LogIf ( ctx , err )
writeErrorResponse ( w , ErrMalformedPOSTRequest , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMalformedPOSTRequest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -533,13 +540,13 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
fileBody , fileName , fileSize , formValues , err := extractPostPolicyFormValues ( ctx , form )
if err != nil {
logger . LogIf ( ctx , err )
writeErrorResponse ( w , ErrMalformedPOSTRequest , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMalformedPOSTRequest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Check if file is provided, error out otherwise.
if fileBody == nil {
writeErrorResponse ( w , ErrPOSTFileRequired , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrPOSTFileRequired ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -561,21 +568,21 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
if successRedirect != "" {
redirectURL , err = url . Parse ( successRedirect )
if err != nil {
writeErrorResponse ( w , ErrMalformedPOSTRequest , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMalformedPOSTRequest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}
// Verify policy signature.
apiErr := doesPolicySignatureMatch ( formValues )
if apiErr != ErrNone {
writeErrorResponse ( w , apiErr , r . URL , guessIsBrowserReq ( r ) )
errCode := doesPolicySignatureMatch ( formValues )
if errCode != ErrNone {
writeErrorResponse ( w , errorCodes . ToAPIErr ( errCode ) , r . URL , guessIsBrowserReq ( r ) )
return
}
policyBytes , err := base64 . StdEncoding . DecodeString ( formValues . Get ( "Policy" ) )
if err != nil {
writeErrorResponse ( w , ErrMalformedPOSTRequest , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMalformedPOSTRequest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -583,13 +590,13 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
if len ( policyBytes ) > 0 {
postPolicyForm , err := parsePostPolicyForm ( string ( policyBytes ) )
if err != nil {
writeErrorResponse ( w , ErrMalformedPOSTRequest , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrMalformedPOSTRequest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Make sure formValues adhere to policy restrictions.
if apiErr = checkPostPolicy ( formValues , postPolicyForm ) ; apiErr != ErrNone {
writeErrorResponse ( w , apiErr , r . URL , guessIsBrowserReq ( r ) )
if errCode = checkPostPolicy ( formValues , postPolicyForm ) ; errCode != ErrNone {
writeErrorResponse ( w , errorCodes . ToAPIErr ( errCode ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -598,12 +605,12 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
lengthRange := postPolicyForm . Conditions . ContentLengthRange
if lengthRange . Valid {
if fileSize < lengthRange . Min {
writeErrorResponse ( w , toAPIErrorCode ( ctx , errDataTooSmall ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , errDataTooSmall ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if fileSize > lengthRange . Max || isMaxObjectSize ( fileSize ) {
writeErrorResponse ( w , toAPIErrorCode ( ctx , errDataTooLarge ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , errDataTooLarge ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}
@ -613,14 +620,14 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
metadata := make ( map [ string ] string )
err = extractMetadataFromMap ( ctx , formValues , metadata )
if err != nil {
writeErrorResponse ( w , ErrInternalError , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
hashReader , err := hash . NewReader ( fileBody , fileSize , "" , "" , fileSize )
if err != nil {
logger . LogIf ( ctx , err )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
rawReader := hashReader
@ -635,7 +642,7 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
var opts ObjectOptions
opts , err = putOpts ( ctx , r , bucket , object , metadata )
if err != nil {
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( ctx , err ) )
writeErrorResponseHeadersOnly ( w , toAPIError ( ctx , err ) )
return
}
if objectAPI . IsEncryptionSupported ( ) {
@ -645,19 +652,19 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
if crypto . SSEC . IsRequested ( formValues ) {
key , err = ParseSSECustomerHeader ( formValues )
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}
reader , objectEncryptionKey , err = newEncryptReader ( hashReader , key , bucket , object , metadata , crypto . S3 . IsRequested ( formValues ) )
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
info := ObjectInfo { Size : fileSize }
hashReader , err = hash . NewReader ( reader , info . EncryptedSize ( ) , "" , "" , fileSize ) // do not try to verify encrypted content
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
pReader = NewPutObjReader ( rawReader , hashReader , objectEncryptionKey )
@ -666,7 +673,7 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
objInfo , err := objectAPI . PutObject ( ctx , bucket , object , pReader , opts )
if err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -732,12 +739,12 @@ func (api objectAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.Re
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
writeErrorResponseHeadersOnly ( w , ErrServerNotInitialized )
writeErrorResponseHeadersOnly ( w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) )
return
}
if s3Error := checkRequestAuthType ( ctx , r , policy . ListBucketAction , bucket , "" ) ; s3Error != ErrNone {
writeErrorResponseHeadersOnly ( w , s3Error )
writeErrorResponseHeadersOnly ( w , errorCodes . ToAPIErr ( s3Error ) )
return
}
@ -746,7 +753,7 @@ func (api objectAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.Re
getBucketInfo = api . CacheAPI ( ) . GetBucketInfo
}
if _ , err := getBucketInfo ( ctx , bucket ) ; err != nil {
writeErrorResponseHeadersOnly ( w , toAPIErrorCode ( ctx , err ) )
writeErrorResponseHeadersOnly ( w , toAPIError ( ctx , err ) )
return
}
@ -764,12 +771,12 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
writeErrorResponse ( w , ErrServerNotInitialized , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if s3Error := checkRequestAuthType ( ctx , r , policy . DeleteBucketAction , bucket , "" ) ; s3Error != ErrNone {
writeErrorResponse ( w , s3Error , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -779,7 +786,7 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.
}
// Attempt to delete bucket.
if err := deleteBucket ( ctx , bucket ) ; err != nil {
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -791,7 +798,7 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.
if err := globalDNSConfig . Delete ( bucket ) ; err != nil {
// Deleting DNS entry failed, attempt to create the bucket again.
objectAPI . MakeBucketWithLocation ( ctx , bucket , "" )
writeErrorResponse ( w , toAPIErrorCode ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}