|
|
@ -1072,6 +1072,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
// If x-amz-tagging-directive header is REPLACE, get passed tags.
|
|
|
|
// If x-amz-tagging-directive header is REPLACE, get passed tags.
|
|
|
|
if isDirectiveReplace(r.Header.Get(xhttp.AmzTagDirective)) { |
|
|
|
if isDirectiveReplace(r.Header.Get(xhttp.AmzTagDirective)) { |
|
|
|
objTags = r.Header.Get(xhttp.AmzObjectTagging) |
|
|
|
objTags = r.Header.Get(xhttp.AmzObjectTagging) |
|
|
|
|
|
|
|
srcInfo.UserDefined[xhttp.AmzTagDirective] = replaceDirective |
|
|
|
if _, err := tags.ParseObjectTags(objTags); err != nil { |
|
|
|
if _, err := tags.ParseObjectTags(objTags); err != nil { |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
return |
|
|
|
return |
|
|
@ -1147,8 +1148,18 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, rerr), r.URL, guessIsBrowserReq(r)) |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, rerr), r.URL, guessIsBrowserReq(r)) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tag, err := tags.ParseObjectTags(objTags) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
opts := miniogo.PutObjectOptions{ |
|
|
|
|
|
|
|
UserMetadata: srcInfo.UserDefined, |
|
|
|
|
|
|
|
ServerSideEncryption: dstOpts.ServerSideEncryption, |
|
|
|
|
|
|
|
UserTags: tag.ToMap(), |
|
|
|
|
|
|
|
} |
|
|
|
remoteObjInfo, rerr := client.PutObject(dstBucket, dstObject, srcInfo.Reader, |
|
|
|
remoteObjInfo, rerr := client.PutObject(dstBucket, dstObject, srcInfo.Reader, |
|
|
|
srcInfo.Size, "", "", srcInfo.UserDefined, dstOpts.ServerSideEncryption) |
|
|
|
srcInfo.Size, "", "", opts) |
|
|
|
if rerr != nil { |
|
|
|
if rerr != nil { |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, rerr), r.URL, guessIsBrowserReq(r)) |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, rerr), r.URL, guessIsBrowserReq(r)) |
|
|
|
return |
|
|
|
return |
|
|
@ -1284,6 +1295,11 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if objTags := r.Header.Get(xhttp.AmzObjectTagging); objTags != "" { |
|
|
|
if objTags := r.Header.Get(xhttp.AmzObjectTagging); objTags != "" { |
|
|
|
|
|
|
|
if !objectAPI.IsTaggingSupported() { |
|
|
|
|
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrNotImplemented), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if _, err := tags.ParseObjectTags(objTags); err != nil { |
|
|
|
if _, err := tags.ParseObjectTags(objTags); err != nil { |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
return |
|
|
|
return |
|
|
@ -2946,6 +2962,10 @@ func (api objectAPIHandlers) GetObjectTaggingHandler(w http.ResponseWriter, r *h |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !objAPI.IsTaggingSupported() { |
|
|
|
|
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrNotImplemented), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
// Allow getObjectTagging if policy action is set.
|
|
|
|
// Allow getObjectTagging if policy action is set.
|
|
|
|
if s3Error := checkRequestAuthType(ctx, r, policy.GetObjectTaggingAction, bucket, object); s3Error != ErrNone { |
|
|
|
if s3Error := checkRequestAuthType(ctx, r, policy.GetObjectTaggingAction, bucket, object); s3Error != ErrNone { |
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL, guessIsBrowserReq(r)) |
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL, guessIsBrowserReq(r)) |
|
|
@ -2953,7 +2973,7 @@ func (api objectAPIHandlers) GetObjectTaggingHandler(w http.ResponseWriter, r *h |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get object tags
|
|
|
|
// Get object tags
|
|
|
|
tags, err := objAPI.GetObjectTag(ctx, bucket, object) |
|
|
|
tags, err := objAPI.GetObjectTags(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 |
|
|
@ -2980,6 +3000,10 @@ func (api objectAPIHandlers) PutObjectTaggingHandler(w http.ResponseWriter, r *h |
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL, guessIsBrowserReq(r)) |
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL, guessIsBrowserReq(r)) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if !objAPI.IsTaggingSupported() { |
|
|
|
|
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrNotImplemented), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Allow putObjectTagging if policy action is set
|
|
|
|
// Allow putObjectTagging if policy action is set
|
|
|
|
if s3Error := checkRequestAuthType(ctx, r, policy.PutObjectTaggingAction, bucket, object); s3Error != ErrNone { |
|
|
|
if s3Error := checkRequestAuthType(ctx, r, policy.PutObjectTaggingAction, bucket, object); s3Error != ErrNone { |
|
|
@ -2994,7 +3018,7 @@ func (api objectAPIHandlers) PutObjectTaggingHandler(w http.ResponseWriter, r *h |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Put object tags
|
|
|
|
// Put object tags
|
|
|
|
err = objAPI.PutObjectTag(ctx, bucket, object, tags.String()) |
|
|
|
err = objAPI.PutObjectTags(ctx, bucket, object, tags.String()) |
|
|
|
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 |
|
|
@ -3013,6 +3037,10 @@ func (api objectAPIHandlers) DeleteObjectTaggingHandler(w http.ResponseWriter, r |
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL, guessIsBrowserReq(r)) |
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL, guessIsBrowserReq(r)) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if !objAPI.IsTaggingSupported() { |
|
|
|
|
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrNotImplemented), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vars := mux.Vars(r) |
|
|
|
vars := mux.Vars(r) |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
@ -3029,7 +3057,7 @@ func (api objectAPIHandlers) DeleteObjectTaggingHandler(w http.ResponseWriter, r |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Delete object tags
|
|
|
|
// Delete object tags
|
|
|
|
if err = objAPI.DeleteObjectTag(ctx, bucket, object); err != nil && err != errConfigNotFound { |
|
|
|
if err = objAPI.DeleteObjectTags(ctx, bucket, object); err != nil && err != errConfigNotFound { |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|