SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
fix s3 ListAllMyBucketsResult to work with s3cmd
Chris Lu3339325334b3
diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.goindex df9abd4511..1d319e354d 100644--- a/weed/s3api/s3api_bucket_handlers.go+++ b/weed/s3api/s3api_bucket_handlers.go@@ -3,10 +3,13 @@ package s3apiimport ("context""fmt"+ "math""net/http""os""time"+ "github.com/aws/aws-sdk-go/aws"+ "github.com/aws/aws-sdk-go/service/s3""github.com/chrislusf/seaweedfs/weed/glog""github.com/chrislusf/seaweedfs/weed/pb/filer_pb""github.com/gorilla/mux"@@ -17,37 +20,38 @@ var (OS_GID = uint32(os.Getgid()))+type ListAllMyBucketsResult struct {+ Buckets []*s3.Bucket `xml:"Buckets>Bucket"`+ Owner *s3.Owner+}+func (s3a *S3ApiServer) ListBucketsHandler(w http.ResponseWriter, r *http.Request) {- var response ListAllMyBucketsResponse+ var response ListAllMyBucketsResult- entries, err := s3a.list(s3a.option.BucketsPath, "", "", false, 0)+ entries, err := s3a.list(s3a.option.BucketsPath, "", "", false, math.MaxInt32)if err != nil {writeErrorResponse(w, ErrInternalError, r.URL)return}- var buckets []ListAllMyBucketsEntry+ var buckets []*s3.Bucketfor _, entry := range entries {if entry.IsDirectory {- buckets = append(buckets, ListAllMyBucketsEntry{- Name: entry.Name,- CreationDate: time.Unix(entry.Attributes.Crtime, 0),+ buckets = append(buckets, &s3.Bucket{+ Name: aws.String(entry.Name),+ CreationDate: aws.Time(time.Unix(entry.Attributes.Crtime, 0)),})}}- response = ListAllMyBucketsResponse{- ListAllMyBucketsResponse: ListAllMyBucketsResult{- Owner: CanonicalUser{- ID: "",- DisplayName: "",- },- Buckets: ListAllMyBucketsList{- Bucket: buckets,- },+ response = ListAllMyBucketsResult{+ Owner: &s3.Owner{+ ID: aws.String(""),+ DisplayName: aws.String(""),},+ Buckets: buckets,}writeSuccessResponseXML(w, encodeResponse(response))diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.goindex 281fc90007..2863983106 100644--- a/weed/s3api/s3api_handlers.go+++ b/weed/s3api/s3api_handlers.go@@ -77,6 +77,7 @@ func writeResponse(w http.ResponseWriter, statusCode int, response []byte, mType}w.WriteHeader(statusCode)if response != nil {+ glog.V(4).Infof("status %d %s: %s", statusCode, mType, string(response))w.Write(response)w.(http.Flusher).Flush()}diff --git a/weed/s3api/s3api_xsd_generated.go b/weed/s3api/s3api_xsd_generated.goindex 915b74ec4e..df07f3feac 100644--- a/weed/s3api/s3api_xsd_generated.go+++ b/weed/s3api/s3api_xsd_generated.go@@ -539,11 +539,6 @@ type ListAllMyBucketsResponse struct {ListAllMyBucketsResponse ListAllMyBucketsResult `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResponse"`}-type ListAllMyBucketsResult struct {- Owner CanonicalUser `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Owner"`- Buckets ListAllMyBucketsList `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Buckets"`-}-type ListBucket struct {Bucket string `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Bucket"`Prefix string `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Prefix,omitempty"`