mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
commit
326fcdd86b
|
@ -97,7 +97,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
|
||||||
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, "x-amz-tagging-") {
|
if strings.HasPrefix(k, "X-Amz-Tagging-") {
|
||||||
tagCount++
|
tagCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,8 @@ func (fs *FilerServer) saveMetaData(ctx context.Context, r *http.Request, fileNa
|
||||||
Size: chunkOffset,
|
Size: chunkOffset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.saveAmzMetaData(r, entry)
|
||||||
|
|
||||||
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
|
||||||
|
@ -308,3 +310,36 @@ func (fs *FilerServer) mkdir(ctx context.Context, w http.ResponseWriter, r *http
|
||||||
}
|
}
|
||||||
return filerResult, replyerr
|
return filerResult, replyerr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fs *FilerServer) saveAmzMetaData(r *http.Request, entry *filer.Entry) {
|
||||||
|
var (
|
||||||
|
storageClass = "X-Amz-Storage-Class"
|
||||||
|
objectTagging = "X-Amz-Tagging"
|
||||||
|
userMetaPrefix = "X-Amz-Meta-"
|
||||||
|
)
|
||||||
|
|
||||||
|
if entry.Extended == nil {
|
||||||
|
entry.Extended = make(map[string][]byte)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sc := r.Header.Get(storageClass); sc != "" {
|
||||||
|
entry.Extended[storageClass] = []byte(sc)
|
||||||
|
}
|
||||||
|
|
||||||
|
if tags := r.Header.Get(objectTagging); tags != "" {
|
||||||
|
for _, v := range strings.Split(tags, "&") {
|
||||||
|
tag := strings.Split(v, "=")
|
||||||
|
if len(tag) == 2 {
|
||||||
|
entry.Extended[objectTagging+"-"+tag[0]] = []byte(tag[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for header, values := range r.Header {
|
||||||
|
if strings.HasPrefix(header, userMetaPrefix) {
|
||||||
|
for _, value := range values {
|
||||||
|
entry.Extended[header] = []byte(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue