From 5ffc733eecc328ded7722200d6fa8dcccc08b6ec Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 24 Jul 2020 21:16:54 -0700 Subject: [PATCH] fix: enforce bucket quota from browser uploads (#10129) --- cmd/web-handlers.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/web-handlers.go b/cmd/web-handlers.go index f080a67a0..376d8cbef 100644 --- a/cmd/web-handlers.go +++ b/cmd/web-handlers.go @@ -1037,6 +1037,11 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) { return } + if err := enforceBucketQuota(ctx, bucket, size); err != nil { + writeWebErrorResponse(w, err) + return + } + // Extract incoming metadata if any. metadata, err := extractMetadata(ctx, r) if err != nil { @@ -2201,6 +2206,8 @@ func toWebAPIError(ctx context.Context, err error) APIError { switch err.(type) { case StorageFull: return getAPIError(ErrStorageFull) + case BucketQuotaExceeded: + return getAPIError(ErrAdminBucketQuotaExceeded) case BucketNotFound: return getAPIError(ErrNoSuchBucket) case BucketNotEmpty: