@ -109,7 +109,11 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r
}
}
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// get gateway encryption options
// get gateway encryption options
opts , err := getOpts ( ctx , r , bucket , object )
opts , err := getOpts ( ctx , r , bucket , object )
@ -273,7 +277,11 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
}
}
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
@ -451,7 +459,11 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
}
}
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
writeErrorResponseHeadersOnly ( w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) )
writeErrorResponseHeadersOnly ( w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) )
@ -704,7 +716,11 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
}
}
vars := mux . Vars ( r )
vars := mux . Vars ( r )
dstBucket := vars [ "bucket" ]
dstBucket := vars [ "bucket" ]
dstObject := vars [ "object" ]
dstObject , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if s3Error := checkRequestAuthType ( ctx , r , policy . PutObjectAction , dstBucket , dstObject ) ; s3Error != ErrNone {
if s3Error := checkRequestAuthType ( ctx , r , policy . PutObjectAction , dstBucket , dstObject ) ; s3Error != ErrNone {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
@ -774,7 +790,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
}
}
var srcOpts , dstOpts ObjectOptions
var srcOpts , dstOpts ObjectOptions
srcOpts , err : = copySrcOpts ( ctx , r , srcBucket , srcObject )
srcOpts , err = copySrcOpts ( ctx , r , srcBucket , srcObject )
if err != nil {
if err != nil {
logger . LogIf ( ctx , err )
logger . LogIf ( ctx , err )
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
@ -1139,7 +1155,11 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
}
}
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// To detect if the client has disconnected.
// To detect if the client has disconnected.
r . Body = & detectDisconnect { r . Body , r . Context ( ) . Done ( ) }
r . Body = & detectDisconnect { r . Body , r . Context ( ) . Done ( ) }
@ -1428,7 +1448,11 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r
}
}
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if s3Error := checkRequestAuthType ( ctx , r , policy . PutObjectAction , bucket , object ) ; s3Error != ErrNone {
if s3Error := checkRequestAuthType ( ctx , r , policy . PutObjectAction , bucket , object ) ; s3Error != ErrNone {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
@ -1443,7 +1467,6 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r
// get gateway encryption options
// get gateway encryption options
var opts ObjectOptions
var opts ObjectOptions
var err error
opts , err = putOpts ( ctx , r , bucket , object , nil )
opts , err = putOpts ( ctx , r , bucket , object , nil )
if err != nil {
if err != nil {
@ -1550,7 +1573,11 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
vars := mux . Vars ( r )
vars := mux . Vars ( r )
dstBucket := vars [ "bucket" ]
dstBucket := vars [ "bucket" ]
dstObject := vars [ "object" ]
dstObject , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if s3Error := checkRequestAuthType ( ctx , r , policy . PutObjectAction , dstBucket , dstObject ) ; s3Error != ErrNone {
if s3Error := checkRequestAuthType ( ctx , r , policy . PutObjectAction , dstBucket , dstObject ) ; s3Error != ErrNone {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
@ -1866,7 +1893,11 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
}
}
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// X-Amz-Copy-Source shouldn't be set for this call.
// X-Amz-Copy-Source shouldn't be set for this call.
if _ , ok := r . Header [ xhttp . AmzCopySource ] ; ok {
if _ , ok := r . Header [ xhttp . AmzCopySource ] ; ok {
@ -2108,7 +2139,11 @@ func (api objectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter,
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
objectAPI := api . ObjectAPI ( )
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
if objectAPI == nil {
@ -2143,7 +2178,11 @@ func (api objectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *ht
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
objectAPI := api . ObjectAPI ( )
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
if objectAPI == nil {
@ -2277,7 +2316,11 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
objectAPI := api . ObjectAPI ( )
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
if objectAPI == nil {
@ -2474,7 +2517,11 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
objectAPI := api . ObjectAPI ( )
objectAPI := api . ObjectAPI ( )
if objectAPI == nil {
if objectAPI == nil {
@ -2532,7 +2579,11 @@ func (api objectAPIHandlers) PutObjectLegalHoldHandler(w http.ResponseWriter, r
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
@ -2630,7 +2681,11 @@ func (api objectAPIHandlers) GetObjectLegalHoldHandler(w http.ResponseWriter, r
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
@ -2687,7 +2742,11 @@ func (api objectAPIHandlers) PutObjectRetentionHandler(w http.ResponseWriter, r
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
@ -2779,7 +2838,11 @@ func (api objectAPIHandlers) GetObjectRetentionHandler(w http.ResponseWriter, r
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
if vid := r . URL . Query ( ) . Get ( "versionId" ) ; vid != "" && vid != "null" {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrNoSuchVersion ) , r . URL , guessIsBrowserReq ( r ) )
@ -2835,7 +2898,11 @@ func (api objectAPIHandlers) GetObjectTaggingHandler(w http.ResponseWriter, r *h
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
objAPI := api . ObjectAPI ( )
objAPI := api . ObjectAPI ( )
if objAPI == nil {
if objAPI == nil {
@ -2866,7 +2933,11 @@ func (api objectAPIHandlers) PutObjectTaggingHandler(w http.ResponseWriter, r *h
vars := mux . Vars ( r )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
bucket := vars [ "bucket" ]
object := vars [ "object" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
objAPI := api . ObjectAPI ( )
objAPI := api . ObjectAPI ( )
if objAPI == nil {
if objAPI == nil {
@ -2901,16 +2972,20 @@ func (api objectAPIHandlers) DeleteObjectTaggingHandler(w http.ResponseWriter, r
ctx := newContext ( r , w , "DeleteObjectTagging" )
ctx := newContext ( r , w , "DeleteObjectTagging" )
defer logger . AuditLog ( w , r , "DeleteObjectTagging" , mustGetClaimsFromToken ( r ) )
defer logger . AuditLog ( w , r , "DeleteObjectTagging" , mustGetClaimsFromToken ( r ) )
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
object := vars [ "object" ]
objAPI := api . ObjectAPI ( )
objAPI := api . ObjectAPI ( )
if objAPI == nil {
if objAPI == nil {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrServerNotInitialized ) , r . URL , guessIsBrowserReq ( r ) )
return
return
}
}
vars := mux . Vars ( r )
bucket := vars [ "bucket" ]
object , err := url . PathUnescape ( vars [ "object" ] )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Allow deleteObjectTagging if policy action is set
// Allow deleteObjectTagging if policy action is set
if s3Error := checkRequestAuthType ( ctx , r , policy . DeleteObjectTaggingAction , bucket , object ) ; s3Error != ErrNone {
if s3Error := checkRequestAuthType ( ctx , r , policy . DeleteObjectTaggingAction , bucket , object ) ; s3Error != ErrNone {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Error ) , r . URL , guessIsBrowserReq ( r ) )
@ -2918,7 +2993,7 @@ func (api objectAPIHandlers) DeleteObjectTaggingHandler(w http.ResponseWriter, r
}
}
// Delete object tags
// Delete object tags
err : = objAPI . DeleteObjectTag ( ctx , bucket , object )
err = objAPI . DeleteObjectTag ( ctx , bucket , object )
if err != nil {
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
return