From 7f6152f13034f354f226af2be3c658ceb14e6e73 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:25:17 +0500 Subject: [PATCH] s3 api add default response for GetBucketVersioning --- weed/s3api/s3api_bucket_handlers.go | 17 +++++++++++++++++ weed/s3api/s3api_server.go | 3 +++ 2 files changed, 20 insertions(+) diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index 3bf5a598b..c1bb815a9 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -533,3 +533,20 @@ func (s3a *S3ApiServer) DeleteBucketOwnershipControls(w http.ResponseWriter, r * } s3err.WriteAwsXMLResponse(w, r, http.StatusOK, emptyOwnershipControls) } + +// GetBucketVersioningHandler Get Bucket Versioning status +// https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketVersioning.html +func (s3a *S3ApiServer) GetBucketVersioningHandler(w http.ResponseWriter, r *http.Request) { + bucket, _ := s3_constants.GetBucketAndObject(r) + glog.V(3).Infof("GetBucketVersioning %s", bucket) + + if err := s3a.checkBucket(r, bucket); err != s3err.ErrNone { + s3err.WriteErrorResponse(w, r, err) + return + } + + result := &s3.VersioningConfiguration{} + result.SetStatus(s3.BucketVersioningStatusSuspended) + + s3err.WriteAwsXMLResponse(w, r, http.StatusOK, result) +} diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go index 1767090f1..6d2ea8f0d 100644 --- a/weed/s3api/s3api_server.go +++ b/weed/s3api/s3api_server.go @@ -222,6 +222,9 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) { // GetBucketRequestPayment bucket.Methods("GET").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.GetBucketRequestPaymentHandler, ACTION_READ)), "GET")).Queries("requestPayment", "") + // GetBucketVersioning + bucket.Methods("GET").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.GetBucketVersioningHandler, ACTION_READ)), "GET")).Queries("versioning", "") + // ListObjectsV2 bucket.Methods("GET").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.ListObjectsV2Handler, ACTION_LIST)), "LIST")).Queries("list-type", "2")