forked from TrueCloudLab/frostfs-s3-gw
[#131] Add meta to PutObject
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
e7bebcc1aa
commit
e8bf46a2fa
2 changed files with 16 additions and 0 deletions
|
@ -47,11 +47,14 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
metadata := parseMetadata(r)
|
||||
|
||||
params := &layer.PutObjectParams{
|
||||
Bucket: bkt,
|
||||
Object: obj,
|
||||
Reader: r.Body,
|
||||
Size: r.ContentLength,
|
||||
Header: metadata,
|
||||
}
|
||||
|
||||
if info, err = h.obj.PutObject(r.Context(), params); err != nil {
|
||||
|
@ -74,6 +77,17 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) {
|
|||
api.WriteSuccessResponseHeadersOnly(w)
|
||||
}
|
||||
|
||||
func parseMetadata(r *http.Request) map[string]string {
|
||||
res := make(map[string]string)
|
||||
for k, v := range r.Header {
|
||||
if strings.HasPrefix(k, api.MetadataPrefix) {
|
||||
key := strings.TrimPrefix(k, api.MetadataPrefix)
|
||||
res[key] = v[0]
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var (
|
||||
err error
|
||||
|
|
|
@ -2,6 +2,8 @@ package api
|
|||
|
||||
// Standard S3 HTTP request/response constants.
|
||||
const (
|
||||
MetadataPrefix = "X-Amz-Meta-"
|
||||
|
||||
LastModified = "Last-Modified"
|
||||
Date = "Date"
|
||||
ETag = "ETag"
|
||||
|
|
Loading…
Reference in a new issue