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
s3: report metadata if the directory is explicitly created (#3498)
Konstantin Lebedevf7aeb06544ef
diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.goindex 1525889fd0..7a423d5246 100644--- a/weed/s3api/s3api_object_handlers.go+++ b/weed/s3api/s3api_object_handlers.go@@ -93,13 +93,15 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request)defer dataReader.Close()objectContentType := r.Header.Get("Content-Type")- if strings.HasSuffix(object, "/") {- if err := s3a.mkdir(s3a.option.BucketsPath, bucket+strings.TrimSuffix(object, "/"), func(entry *filer_pb.Entry) {- if objectContentType == "" {- objectContentType = "httpd/unix-directory"- }- entry.Attributes.Mime = objectContentType- }); err != nil {+ if strings.HasSuffix(object, "/") && r.ContentLength == 0 {+ if err := s3a.mkdir(+ s3a.option.BucketsPath, bucket+strings.TrimSuffix(object, "/"),+ func(entry *filer_pb.Entry) {+ if objectContentType == "" {+ objectContentType = "httpd/unix-directory"+ }+ entry.Attributes.Mime = objectContentType+ }); err != nil {s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)return}@@ -314,7 +316,7 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *hfunc (s3a *S3ApiServer) doDeleteEmptyDirectories(client filer_pb.SeaweedFilerClient, directoriesWithDeletion map[string]int) (newDirectoriesWithDeletion map[string]int) {var allDirs []string- for dir, _ := range directoriesWithDeletion {+ for dir := range directoriesWithDeletion {allDirs = append(allDirs, dir)}slices.SortFunc(allDirs, func(a, b string) bool {diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.goindex 58df2f5245..327eaa54d0 100644--- a/weed/server/filer_server_handlers_read.go+++ b/weed/server/filer_server_handlers_read.go@@ -25,10 +25,11 @@ import (// Validates the preconditions. Returns true if GET/HEAD operation should not proceed.// Preconditions supported are:-// If-Modified-Since-// If-Unmodified-Since-// If-Match-// If-None-Match+//+// If-Modified-Since+// If-Unmodified-Since+// If-Match+// If-None-Matchfunc checkPreconditions(w http.ResponseWriter, r *http.Request, entry *filer.Entry) bool {etag := filer.ETagEntry(entry)@@ -111,12 +112,12 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)w.WriteHeader(http.StatusMethodNotAllowed)return}- if entry.Attr.Mime != "" {- // inform S3 API this is a user created directory key object- w.Header().Set(s3_constants.X_SeaweedFS_Header_Directory_Key, "true")+ if entry.Attr.Mime == "" {+ fs.listDirectoryHandler(w, r)+ return}- fs.listDirectoryHandler(w, r)- return+ // inform S3 API this is a user created directory key object+ w.Header().Set(s3_constants.X_SeaweedFS_Header_Directory_Key, "true")}if isForDirectory {