mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
s3 fix get fake dir object key (#4390)
This commit is contained in:
parent
d1ce89950e
commit
130bc3e668
|
@ -9,4 +9,5 @@ const (
|
||||||
|
|
||||||
SeaweedStorageDestinationHeader = "x-seaweedfs-destination"
|
SeaweedStorageDestinationHeader = "x-seaweedfs-destination"
|
||||||
MultipartUploadsFolder = ".uploads"
|
MultipartUploadsFolder = ".uploads"
|
||||||
|
FolderMimeType = "httpd/unix-directory"
|
||||||
)
|
)
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request)
|
||||||
s3a.option.BucketsPath, bucket+strings.TrimSuffix(object, "/"),
|
s3a.option.BucketsPath, bucket+strings.TrimSuffix(object, "/"),
|
||||||
func(entry *filer_pb.Entry) {
|
func(entry *filer_pb.Entry) {
|
||||||
if objectContentType == "" {
|
if objectContentType == "" {
|
||||||
objectContentType = "httpd/unix-directory"
|
objectContentType = s3_constants.FolderMimeType
|
||||||
}
|
}
|
||||||
entry.Attributes.Mime = objectContentType
|
entry.Attributes.Mime = objectContentType
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|
|
@ -15,8 +15,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/exp/slices"
|
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/filer"
|
"github.com/seaweedfs/seaweedfs/weed/filer"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/images"
|
"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)
|
writeJsonQuiet(w, r, http.StatusOK, entry)
|
||||||
return
|
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)
|
fs.listDirectoryHandler(w, r)
|
||||||
return
|
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")
|
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)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue