From 6d529d5d8e6d91e44c23e61037580c6f84988825 Mon Sep 17 00:00:00 2001 From: Benjamin Fransson <32129592+erhuz@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:55:36 +0100 Subject: [PATCH] Detect MIME type on upload instead of hardcoding application/octet-stream --- internal/app/s3manager/create_object.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/app/s3manager/create_object.go b/internal/app/s3manager/create_object.go index b51a8f9..5869bee 100644 --- a/internal/app/s3manager/create_object.go +++ b/internal/app/s3manager/create_object.go @@ -3,7 +3,9 @@ package s3manager import ( "fmt" "log" + "mime" "net/http" + "path/filepath" "github.com/gorilla/mux" "github.com/minio/minio-go/v7" @@ -32,7 +34,14 @@ func HandleCreateObject(s3 S3, sseInfo SSEType) http.HandlerFunc { } }() - opts := minio.PutObjectOptions{ContentType: "application/octet-stream"} + contentType := fileHeader.Header.Get("Content-Type") + if contentType == "" || contentType == "application/octet-stream" { + contentType = mime.TypeByExtension(filepath.Ext(fileHeader.Filename)) + } + if contentType == "" { + contentType = "application/octet-stream" + } + opts := minio.PutObjectOptions{ContentType: contentType} if sseInfo.Type == "KMS" { opts.ServerSideEncryption, err = encrypt.NewSSEKMS(sseInfo.Key, nil)