mirror of
https://github.com/chrislusf/seaweedfs
synced 2024-07-06 17:17:25 +02:00
filer: Headers with "Seaweed-" prefix are stored as extended properties
This commit is contained in:
parent
0ecff9521d
commit
5448781dfc
|
@ -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++
|
||||||
}
|
}
|
||||||
|
|
|
@ -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…
Reference in a new issue