Repository: minio/minio (language: go)

Issue:
Wrong content type with x-amz-meta-snowball-auto-extract
I have reasons to use the undocumented x-amz-meta-snowball-auto-extract functionality, which gives the ability of uploading many files in one request.

As I noted there are issues with the content type. If I upload a .js file as part of a tar-stream, I will get the content type "binary/octet-stream".
Otherwise it's "application/x-javascript".

I cannot find a solution to set the right content type. In my opinion it should be possible to configure a manual mapping.


Discussion / hints:
We can try to auto interpret it on the server. Tar has no way to specify the right content type.
I would expect the same behaviour as with single upload when no content type is explicit set.
In this case I assume the content type will be mapped at upload time not at request time.

Besides that, is it possible to expand the mapping?
We can that's easy part. 

Fix patch:
diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go
index a9f6dc5e69722..f20dca22ac100 100644
--- a/cmd/object-handlers.go
+++ b/cmd/object-handlers.go
@@ -2111,36 +2111,16 @@ 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
-	}
-
-	// Remove the snowball headers from metadata from objects
-	// since those are actionable headers and not for storage
-	delete(metadata, xhttp.AmzSnowballExtract)
-	delete(metadata, xhttp.AmzSnowballExtract)
-	delete(metadata, xhttp.MinIOSnowballIgnoreDirs)
-	delete(metadata, xhttp.MinIOSnowballIgnoreErrors)
-	delete(metadata, xhttp.MinIOSnowballPrefix)
-
-	// Use the same storage class as the original uploaded tar file
-	if sc != "" {
-		metadata[xhttp.AmzStorageClass] = sc
-	}
-
 	putObjectTar := func(reader io.Reader, info os.FileInfo, object string) error {
 		size := info.Size()
 
-		// 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
+		if sc == "" {
+			sc = storageclass.STANDARD
+		}
+
+		metadata := map[string]string{
+			xhttp.AmzStorageClass: sc, // save same storage-class as incoming stream.
 		}
-		// Shadow now...
-		metadata := metaCopy
 
 		actualSize := size
 		var idxCb func() []byte


Test patch: