From f66625be67c16c64aa4941634e3cd67826be64c2 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Mon, 17 Apr 2023 12:16:54 -0700 Subject: [PATCH] Snowball: Extract headers for metadata (#17042) --- cmd/object-handlers.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 4b4858ec7..3052ae4c4 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -2078,11 +2078,24 @@ func (api objectAPIHandlers) PutObjectExtractHandler(w http.ResponseWriter, r *h getObjectInfo = api.CacheAPI().GetObjectInfo } + // Extract request metadata + metadata, err := extractMetadata(ctx, r) + if err != nil { + writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) + return + } + metadata[xhttp.AmzStorageClass] = sc + putObjectTar := func(reader io.Reader, info os.FileInfo, object string) error { size := info.Size() - metadata := map[string]string{ - xhttp.AmzStorageClass: sc, + + // Copy metadata and make space for a bit more + metaCopy := make(map[string]string, len(metadata)+5) + for k, v := range metadata { + metaCopy[k] = v } + // Shadow now... + metadata := metaCopy actualSize := size var idxCb func() []byte