High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
Use file extension for Content-Type of S3 proxied media (#3330)
Kabeer Ahmed1563d2a33811
diff --git a/cmd/media.go b/cmd/media.goindex 3d8aad7c..e0d02f3a 100644--- a/cmd/media.go+++ b/cmd/media.go@@ -2,6 +2,7 @@ package mainimport ("bytes"+ "mime""mime/multipart""net/http""path/filepath"@@ -270,7 +271,18 @@ func (a *App) ServeS3Media(c *echo.Context) error {return echo.NewHTTPError(http.StatusInternalServerError, "error fetching media")}- return c.Stream(http.StatusOK, http.DetectContentType(b), bytes.NewReader(b))+ // Detect content type from file bites.+ ctype := http.DetectContentType(b)+ switch ctype {+ // Images like SVGs will be detected as text/plain, so for those types, fall back+ // to using the simple file extension check.+ case "text/plain; charset=utf-8", "text/xml; charset=utf-8", "application/octet-stream":+ if typ := mime.TypeByExtension(filepath.Ext(key)); typ != "" {+ ctype = typ+ }+ }++ return c.Stream(http.StatusOK, ctype, bytes.NewReader(b))}// processImage reads the image file and returns thumbnail bytes and