s3: Force a prefix removal using a special header (#12504)

An S3 client can send `x-minio-force-delete: true` to remove a prefix.
This commit is contained in:
Anis Elleuch
2021-06-16 02:43:14 +01:00
committed by GitHub
parent f30c996d48
commit 7722b91e1d
7 changed files with 72 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ import (
"context"
"encoding/hex"
"encoding/xml"
"errors"
"fmt"
"io"
"net/http"
@@ -3270,6 +3271,10 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
apiErr := ErrNone
if rcfg, _ := globalBucketObjectLockSys.Get(bucket); rcfg.LockEnabled {
if opts.DeletePrefix {
writeErrorResponse(ctx, w, toAPIError(ctx, errors.New("force-delete is forbidden in a locked-enabled bucket")), r.URL, guessIsBrowserReq(r))
return
}
if vID != "" {
apiErr = enforceRetentionBypassForDelete(ctx, r, bucket, ObjectToDelete{
ObjectName: object,