Repository: minio/minio (language: go)

Issue:
Incorrect Content-Type text/plain for javascript in zip-archive
Incorrect `Content-Type: text/plain` when requesting assets from `*.zip` archive (javascript and css files).
I tried using minio s3 as static site hosting (html, js, css, images).
I upload `site.zip`, then open `https://***/bucket/site.zip/index.html`.
(In front of `minio` is installed `nginx` with configured `proxy_pass` to `:9000` port and additional `X-Minio-Extract` header).
Thehtml-page opens fine. But all assets are returned with header `Content-Type: text/plain` instead of:
`text/css` and `text/javascript`.
As a result, there is the errors in the browser:
```
Refused to apply style from 'https://***/bucket/site.zip/src/style.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
# and:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
```
So far I've only found a single solution at the Nginx level:
```nginx
    ####
    ## (!) Fixed an error: Refused to apply style from 'https://***/bucket/site.zip/src/style.css' because
    ##     its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
    ####

map $uri $assets_content_type {
    # if $http_host contains the word staging
    "~.+\.js$"  "text/javascript";
    "~.+\.css$" "text/css";
    default     "text/plain";
}

server {
    # ....
    location ~.+\.(js|css)$ {
       ## My: Use Indexing for extract Zip archives (Zip Extract). Example: /site.zip/index.html
       proxy_set_header X-Minio-Extract true;

       ## Proxy to :9000
       proxy_set_header Host $http_host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;

       proxy_connect_timeout 300;
       # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
       proxy_http_version 1.1;
       proxy_set_header Connection "";
       chunked_transfer_encoding off;

       # This uses the upstream directive definition to load balance
       proxy_pass https://minio_s3;

       #proxy_hide_header X-Content-Type-Options;
       proxy_hide_header Content-Type; 
       add_header Content-Type "$assets_content_type";
    }
}

## ...
```

This seems to have solved the problem. But maybe there is a more elegant solution.. Thank you 🤝


Discussion / hints:

Fix patch:
diff --git a/cmd/s3-zip-handlers.go b/cmd/s3-zip-handlers.go
index 6cb2c892e153c..eabe9450c8521 100644
--- a/cmd/s3-zip-handlers.go
+++ b/cmd/s3-zip-handlers.go
@@ -22,7 +22,9 @@ import (
 	"context"
 	"errors"
 	"io"
+	"mime"
 	"net/http"
+	"path/filepath"
 	"sort"
 	"strings"
 
@@ -166,10 +168,11 @@ func (api objectAPIHandlers) getObjectInArchiveFileHandler(ctx context.Context,
 
 	// New object info
 	fileObjInfo := ObjectInfo{
-		Bucket:  bucket,
-		Name:    object,
-		Size:    int64(file.UncompressedSize64),
-		ModTime: zipObjInfo.ModTime,
+		Bucket:      bucket,
+		Name:        object,
+		Size:        int64(file.UncompressedSize64),
+		ModTime:     zipObjInfo.ModTime,
+		ContentType: mime.TypeByExtension(filepath.Ext(object)),
 	}
 
 	var rc io.ReadCloser


Test patch: