Browse Source

s3 fix get fake dir object key (#4390)

pull/4392/head
Konstantin Lebedev 2 years ago
committed by GitHub
parent
commit
130bc3e668
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      weed/s3api/s3_constants/s3_actions.go
  2. 2
      weed/s3api/s3api_object_handlers.go
  3. 7
      weed/server/filer_server_handlers_read.go

1
weed/s3api/s3_constants/s3_actions.go

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

2
weed/s3api/s3api_object_handlers.go

@ -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 {

7
weed/server/filer_server_handlers_read.go

@ -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
}

Loading…
Cancel
Save