mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-20 02:57:59 +08:00
s3: report metadata if the directory is explicitly created (#3498)
* replace mkdir to mkFile * ContentLength must be zero * revert mkDir * Seaweedfs-Is-Directory-Key return metadata
This commit is contained in:

committed by
GitHub

parent
c57c79a0ab
commit
f7aeb06544
@@ -93,13 +93,15 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
defer dataReader.Close()
|
defer dataReader.Close()
|
||||||
|
|
||||||
objectContentType := r.Header.Get("Content-Type")
|
objectContentType := r.Header.Get("Content-Type")
|
||||||
if strings.HasSuffix(object, "/") {
|
if strings.HasSuffix(object, "/") && r.ContentLength == 0 {
|
||||||
if err := s3a.mkdir(s3a.option.BucketsPath, bucket+strings.TrimSuffix(object, "/"), func(entry *filer_pb.Entry) {
|
if err := s3a.mkdir(
|
||||||
if objectContentType == "" {
|
s3a.option.BucketsPath, bucket+strings.TrimSuffix(object, "/"),
|
||||||
objectContentType = "httpd/unix-directory"
|
func(entry *filer_pb.Entry) {
|
||||||
}
|
if objectContentType == "" {
|
||||||
entry.Attributes.Mime = objectContentType
|
objectContentType = "httpd/unix-directory"
|
||||||
}); err != nil {
|
}
|
||||||
|
entry.Attributes.Mime = objectContentType
|
||||||
|
}); err != nil {
|
||||||
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)
|
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -314,7 +316,7 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h
|
|||||||
|
|
||||||
func (s3a *S3ApiServer) doDeleteEmptyDirectories(client filer_pb.SeaweedFilerClient, directoriesWithDeletion map[string]int) (newDirectoriesWithDeletion map[string]int) {
|
func (s3a *S3ApiServer) doDeleteEmptyDirectories(client filer_pb.SeaweedFilerClient, directoriesWithDeletion map[string]int) (newDirectoriesWithDeletion map[string]int) {
|
||||||
var allDirs []string
|
var allDirs []string
|
||||||
for dir, _ := range directoriesWithDeletion {
|
for dir := range directoriesWithDeletion {
|
||||||
allDirs = append(allDirs, dir)
|
allDirs = append(allDirs, dir)
|
||||||
}
|
}
|
||||||
slices.SortFunc(allDirs, func(a, b string) bool {
|
slices.SortFunc(allDirs, func(a, b string) bool {
|
||||||
|
@@ -25,10 +25,11 @@ import (
|
|||||||
|
|
||||||
// Validates the preconditions. Returns true if GET/HEAD operation should not proceed.
|
// Validates the preconditions. Returns true if GET/HEAD operation should not proceed.
|
||||||
// Preconditions supported are:
|
// Preconditions supported are:
|
||||||
// If-Modified-Since
|
//
|
||||||
// If-Unmodified-Since
|
// If-Modified-Since
|
||||||
// If-Match
|
// If-Unmodified-Since
|
||||||
// If-None-Match
|
// If-Match
|
||||||
|
// If-None-Match
|
||||||
func checkPreconditions(w http.ResponseWriter, r *http.Request, entry *filer.Entry) bool {
|
func checkPreconditions(w http.ResponseWriter, r *http.Request, entry *filer.Entry) bool {
|
||||||
|
|
||||||
etag := filer.ETagEntry(entry)
|
etag := filer.ETagEntry(entry)
|
||||||
@@ -111,12 +112,12 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if entry.Attr.Mime != "" {
|
if entry.Attr.Mime == "" {
|
||||||
// inform S3 API this is a user created directory key object
|
fs.listDirectoryHandler(w, r)
|
||||||
w.Header().Set(s3_constants.X_SeaweedFS_Header_Directory_Key, "true")
|
return
|
||||||
}
|
}
|
||||||
fs.listDirectoryHandler(w, r)
|
// inform S3 API this is a user created directory key object
|
||||||
return
|
w.Header().Set(s3_constants.X_SeaweedFS_Header_Directory_Key, "true")
|
||||||
}
|
}
|
||||||
|
|
||||||
if isForDirectory {
|
if isForDirectory {
|
||||||
|
Reference in New Issue
Block a user