s3 fix get fake dir object key (#4390)

This commit is contained in:
Konstantin Lebedev 2023-04-11 19:36:22 +05:00 committed by GitHub
parent d1ce89950e
commit 130bc3e668
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -9,4 +9,5 @@ const (
SeaweedStorageDestinationHeader = "x-seaweedfs-destination"
MultipartUploadsFolder = ".uploads"
FolderMimeType = "httpd/unix-directory"
)

View file

@ -99,7 +99,7 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request)
s3a.option.BucketsPath, bucket+strings.TrimSuffix(object, "/"),
func(entry *filer_pb.Entry) {
if objectContentType == "" {
objectContentType = "httpd/unix-directory"
objectContentType = s3_constants.FolderMimeType
}
entry.Attributes.Mime = objectContentType
}); err != nil {

View file

@ -15,8 +15,6 @@ import (
"strings"
"time"
"golang.org/x/exp/slices"
"github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/images"
@ -120,7 +118,8 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
writeJsonQuiet(w, r, http.StatusOK, entry)
return
}
if slices.Contains([]string{"httpd/unix-directory", ""}, entry.Attr.Mime) {
if entry.Attr.Mime == "" || (entry.Attr.Mime == s3_constants.FolderMimeType && r.Header.Get(s3_constants.AmzIdentityId) == "") {
// return index of directory for non s3 gateway
fs.listDirectoryHandler(w, r)
return
}
@ -128,7 +127,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
w.Header().Set(s3_constants.X_SeaweedFS_Header_Directory_Key, "true")
}
if isForDirectory {
if isForDirectory && entry.Attr.Mime != s3_constants.FolderMimeType {
w.WriteHeader(http.StatusNotFound)
return
}