aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api
diff options
context:
space:
mode:
authorhilimd <68371223+hilimd@users.noreply.github.com>2020-11-05 12:02:47 +0800
committerGitHub <noreply@github.com>2020-11-05 12:02:47 +0800
commit546f1bcb903dd26ba447cdbedb972736fdb31b42 (patch)
tree09b8119faa7162acaa7240de5af6fd0bebe96c2f /weed/s3api
parent843865f2ca534bb6286b7a3d79c436384d875608 (diff)
parent75887ba2a20b9f3f7ff9c4b8998cf3af0c0f48c2 (diff)
downloadseaweedfs-546f1bcb903dd26ba447cdbedb972736fdb31b42.tar.xz
seaweedfs-546f1bcb903dd26ba447cdbedb972736fdb31b42.zip
Merge pull request #34 from chrislusf/master
sync
Diffstat (limited to 'weed/s3api')
-rw-r--r--weed/s3api/filer_util_tags.go3
-rw-r--r--weed/s3api/http/header.go30
-rw-r--r--weed/s3api/s3api_object_handlers.go2
-rw-r--r--weed/s3api/s3api_objects_list_handlers.go9
4 files changed, 40 insertions, 4 deletions
diff --git a/weed/s3api/filer_util_tags.go b/weed/s3api/filer_util_tags.go
index 3d4da7825..75d3b37d0 100644
--- a/weed/s3api/filer_util_tags.go
+++ b/weed/s3api/filer_util_tags.go
@@ -4,10 +4,11 @@ import (
"strings"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ xhttp "github.com/chrislusf/seaweedfs/weed/s3api/http"
)
const (
- S3TAG_PREFIX = "s3-"
+ S3TAG_PREFIX = xhttp.AmzObjectTagging + "-"
)
func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (tags map[string]string, err error) {
diff --git a/weed/s3api/http/header.go b/weed/s3api/http/header.go
new file mode 100644
index 000000000..2802b560f
--- /dev/null
+++ b/weed/s3api/http/header.go
@@ -0,0 +1,30 @@
+/*
+ * MinIO Cloud Storage, (C) 2019 MinIO, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package http
+
+// Standard S3 HTTP request constants
+const (
+ // S3 storage class
+ AmzStorageClass = "x-amz-storage-class"
+
+ // S3 user-defined metadata
+ AmzUserMetaPrefix = "X-Amz-Meta-"
+
+ // S3 object tagging
+ AmzObjectTagging = "X-Amz-Tagging"
+ AmzTagCount = "x-amz-tagging-count"
+)
diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go
index fa628f44e..fe134c102 100644
--- a/weed/s3api/s3api_object_handlers.go
+++ b/weed/s3api/s3api_object_handlers.go
@@ -266,7 +266,7 @@ func (s3a *S3ApiServer) proxyToFiler(w http.ResponseWriter, r *http.Request, des
resp, postErr := client.Do(proxyReq)
- if resp.ContentLength == -1 && !strings.HasSuffix(destUrl, "/") {
+ if (resp.ContentLength == -1 || resp.StatusCode == 404) && !strings.HasSuffix(destUrl, "/") {
writeErrorResponse(w, s3err.ErrNoSuchKey, r.URL)
return
}
diff --git a/weed/s3api/s3api_objects_list_handlers.go b/weed/s3api/s3api_objects_list_handlers.go
index 23406d6df..5d63f1039 100644
--- a/weed/s3api/s3api_objects_list_handlers.go
+++ b/weed/s3api/s3api_objects_list_handlers.go
@@ -4,7 +4,6 @@ import (
"context"
"encoding/xml"
"fmt"
- "github.com/chrislusf/seaweedfs/weed/s3api/s3err"
"io"
"net/http"
"net/url"
@@ -15,6 +14,8 @@ import (
"github.com/chrislusf/seaweedfs/weed/filer"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ xhttp "github.com/chrislusf/seaweedfs/weed/s3api/http"
+ "github.com/chrislusf/seaweedfs/weed/s3api/s3err"
)
type ListBucketResultV2 struct {
@@ -137,6 +138,10 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
})
}
} else {
+ storageClass := "STANDARD"
+ if v, ok := entry.Extended[xhttp.AmzStorageClass]; ok {
+ storageClass = string(v)
+ }
contents = append(contents, ListEntry{
Key: fmt.Sprintf("%s/%s", dir, entry.Name)[len(bucketPrefix):],
LastModified: time.Unix(entry.Attributes.Mtime, 0).UTC(),
@@ -146,7 +151,7 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
ID: fmt.Sprintf("%x", entry.Attributes.Uid),
DisplayName: entry.Attributes.UserName,
},
- StorageClass: "STANDARD",
+ StorageClass: StorageClass(storageClass),
})
}
})