Browse Source

filer: Headers with "Seaweed-" prefix are stored as extended properties

pull/1598/head
Chris Lu 4 years ago
parent
commit
5448781dfc
  1. 7
      weed/server/filer_server_handlers_read.go
  2. 15
      weed/server/filer_server_handlers_write_autochunk.go

7
weed/server/filer_server_handlers_read.go

@ -94,10 +94,15 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
} }
} }
// print out the header from extended properties
for k, v := range entry.Extended {
w.Header().Set(k, string(v))
}
//set tag count //set tag count
if r.Method == "GET" { if r.Method == "GET" {
tagCount := 0 tagCount := 0
for k, _ := range entry.Extended {
for k := range entry.Extended {
if strings.HasPrefix(k, xhttp.AmzObjectTagging+"-") { if strings.HasPrefix(k, xhttp.AmzObjectTagging+"-") {
tagCount++ tagCount++
} }

15
weed/server/filer_server_handlers_write_autochunk.go

@ -21,6 +21,7 @@ import (
xhttp "github.com/chrislusf/seaweedfs/weed/s3api/http" xhttp "github.com/chrislusf/seaweedfs/weed/s3api/http"
"github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/stats" "github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
) )
@ -177,8 +178,18 @@ func (fs *FilerServer) saveMetaData(ctx context.Context, r *http.Request, fileNa
Size: chunkOffset, Size: chunkOffset,
} }
if entry.Extended == nil {
entry.Extended = make(map[string][]byte)
}
fs.saveAmzMetaData(r, entry) fs.saveAmzMetaData(r, entry)
for k, v := range r.Header {
if len(v) > 0 && strings.HasPrefix(k, needle.PairNamePrefix) {
entry.Extended[k[len(needle.PairNamePrefix):]] = []byte(v[0])
}
}
if dbErr := fs.filer.CreateEntry(ctx, entry, false, false, nil); dbErr != nil { if dbErr := fs.filer.CreateEntry(ctx, entry, false, false, nil); dbErr != nil {
fs.filer.DeleteChunks(entry.Chunks) fs.filer.DeleteChunks(entry.Chunks)
replyerr = dbErr replyerr = dbErr
@ -314,10 +325,6 @@ func (fs *FilerServer) mkdir(ctx context.Context, w http.ResponseWriter, r *http
func (fs *FilerServer) saveAmzMetaData(r *http.Request, entry *filer.Entry) { func (fs *FilerServer) saveAmzMetaData(r *http.Request, entry *filer.Entry) {
if entry.Extended == nil {
entry.Extended = make(map[string][]byte)
}
if sc := r.Header.Get(xhttp.AmzStorageClass); sc != "" { if sc := r.Header.Get(xhttp.AmzStorageClass); sc != "" {
entry.Extended[xhttp.AmzStorageClass] = []byte(sc) entry.Extended[xhttp.AmzStorageClass] = []byte(sc)
} }

Loading…
Cancel
Save