Konstantin Lebedev 3 years ago
parent
commit
26f3646961
  1. 5
      weed/s3api/s3api_object_handlers.go
  2. 9
      weed/s3api/s3api_objects_list_handlers.go

5
weed/s3api/s3api_object_handlers.go

@ -93,7 +93,10 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request)
defer dataReader.Close() defer dataReader.Close()
if strings.HasSuffix(object, "/") { if strings.HasSuffix(object, "/") {
if err := s3a.mkdir(s3a.option.BucketsPath, bucket+object, nil); err != nil {
if err := s3a.mkdir(s3a.option.BucketsPath, bucket+strings.TrimSuffix(object, "/"), func(entry *filer_pb.Entry) {
glog.V(0).Infof("make file %s", bucket+object)
entry.Attributes.Mime = r.Header.Get("Content-Type")
}); err != nil {
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError) s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)
return return
} }

9
weed/s3api/s3api_objects_list_handlers.go

@ -134,9 +134,6 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
} }
bucketPrefix := fmt.Sprintf("%s/%s/", s3a.option.BucketsPath, bucket) bucketPrefix := fmt.Sprintf("%s/%s/", s3a.option.BucketsPath, bucket)
reqDir = fmt.Sprintf("%s%s", bucketPrefix, reqDir) reqDir = fmt.Sprintf("%s%s", bucketPrefix, reqDir)
if prefix == "" && strings.HasSuffix(reqDir, "/") {
reqDir, prefix = filepath.Split(reqDir[:len(reqDir)-1])
}
if strings.HasSuffix(reqDir, "/") { if strings.HasSuffix(reqDir, "/") {
// remove trailing "/" // remove trailing "/"
reqDir = reqDir[:len(reqDir)-1] reqDir = reqDir[:len(reqDir)-1]
@ -152,10 +149,12 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
err = s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { err = s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
_, isTruncated, nextMarker, doErr = s3a.doListFilerEntries(client, reqDir, prefix, maxKeys, marker, delimiter, func(dir string, entry *filer_pb.Entry) { _, isTruncated, nextMarker, doErr = s3a.doListFilerEntries(client, reqDir, prefix, maxKeys, marker, delimiter, func(dir string, entry *filer_pb.Entry) {
if entry.IsDirectory && delimiter == "/" {
if entry.IsDirectory && entry.Attributes.Mime == "" {
if delimiter == "/" {
commonPrefixes = append(commonPrefixes, PrefixEntry{ commonPrefixes = append(commonPrefixes, PrefixEntry{
Prefix: fmt.Sprintf("%s/%s/", dir, entry.Name)[len(bucketPrefix):], Prefix: fmt.Sprintf("%s/%s/", dir, entry.Name)[len(bucketPrefix):],
}) })
}
} else { } else {
storageClass := "STANDARD" storageClass := "STANDARD"
if v, ok := entry.Extended[xhttp.AmzStorageClass]; ok { if v, ok := entry.Extended[xhttp.AmzStorageClass]; ok {
@ -294,10 +293,12 @@ func (s3a *S3ApiServer) doListFilerEntries(client filer_pb.SeaweedFilerClient, d
glog.Errorf("check empty folder %s: %v", dir, err) glog.Errorf("check empty folder %s: %v", dir, err)
} }
} }
if !isEmpty || entry.Attributes.Mime != "" {
eachEntryFn(dir, entry) eachEntryFn(dir, entry)
counter++ counter++
} }
} }
}
} else { } else {
// println("ListEntries", dir, "file:", entry.Name) // println("ListEntries", dir, "file:", entry.Name)
eachEntryFn(dir, entry) eachEntryFn(dir, entry)

Loading…
Cancel
Save