From 19026ae55d08ef971be1cfb6b66b75069763c6ae Mon Sep 17 00:00:00 2001
From: "ruitao.liu" <ruitao.liu@cloudminds.com>
Date: Tue, 27 Oct 2020 16:49:31 +0800
Subject: [PATCH 1/3] return x-amz-tag-count header when GET object.

---
 weed/s3api/filer_util_tags.go             |  2 +-
 weed/server/filer_server_handlers_read.go | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/weed/s3api/filer_util_tags.go b/weed/s3api/filer_util_tags.go
index 3d4da7825..fde8e243e 100644
--- a/weed/s3api/filer_util_tags.go
+++ b/weed/s3api/filer_util_tags.go
@@ -7,7 +7,7 @@ import (
 )
 
 const (
-	S3TAG_PREFIX = "s3-"
+	S3TAG_PREFIX = "s3-tag-"
 )
 
 func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (tags map[string]string, err error) {
diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go
index fbd45d6b9..ca584f9f6 100644
--- a/weed/server/filer_server_handlers_read.go
+++ b/weed/server/filer_server_handlers_read.go
@@ -93,6 +93,19 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
 		}
 	}
 
+	//set tag count
+	if r.Method == "GET" {
+		tagCount := 0
+		for k, _ := range entry.Extended {
+			if strings.HasPrefix(k, "s3-tag-") {
+				tagCount++
+			}
+		}
+		if tagCount > 0 {
+			w.Header().Set("x-amz-tag-count", strconv.Itoa(tagCount))
+		}
+	}
+
 	// set etag
 	etag := filer.ETagEntry(entry)
 	if inm := r.Header.Get("If-None-Match"); inm == "\""+etag+"\"" {

From 8766ca1b955a0b142d30c0df55fe18b8d8024d7d Mon Sep 17 00:00:00 2001
From: "ruitao.liu" <ruitao.liu@cloudminds.com>
Date: Tue, 27 Oct 2020 17:33:24 +0800
Subject: [PATCH 2/3] rename s3 tag prefix.

---
 weed/s3api/filer_util_tags.go             | 2 +-
 weed/server/filer_server_handlers_read.go | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/weed/s3api/filer_util_tags.go b/weed/s3api/filer_util_tags.go
index fde8e243e..bdc8f31da 100644
--- a/weed/s3api/filer_util_tags.go
+++ b/weed/s3api/filer_util_tags.go
@@ -7,7 +7,7 @@ import (
 )
 
 const (
-	S3TAG_PREFIX = "s3-tag-"
+	S3TAG_PREFIX = "x-amz-tagging-"
 )
 
 func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (tags map[string]string, err error) {
diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go
index ca584f9f6..1fb24369b 100644
--- a/weed/server/filer_server_handlers_read.go
+++ b/weed/server/filer_server_handlers_read.go
@@ -97,7 +97,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
 	if r.Method == "GET" {
 		tagCount := 0
 		for k, _ := range entry.Extended {
-			if strings.HasPrefix(k, "s3-tag-") {
+			if strings.HasPrefix(k, "x-amz-tagging") {
 				tagCount++
 			}
 		}

From 72f6b77deae239cc324ce30a31bc672fcd419ca2 Mon Sep 17 00:00:00 2001
From: "ruitao.liu" <ruitao.liu@cloudminds.com>
Date: Tue, 27 Oct 2020 18:01:37 +0800
Subject: [PATCH 3/3] fix tag prefix.

---
 weed/server/filer_server_handlers_read.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go
index 1fb24369b..731bd3545 100644
--- a/weed/server/filer_server_handlers_read.go
+++ b/weed/server/filer_server_handlers_read.go
@@ -97,7 +97,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
 	if r.Method == "GET" {
 		tagCount := 0
 		for k, _ := range entry.Extended {
-			if strings.HasPrefix(k, "x-amz-tagging") {
+			if strings.HasPrefix(k, "x-amz-tagging-") {
 				tagCount++
 			}
 		}