From c6370bb7396d3eb0b68a83728a1681985f1f8660 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 21 Feb 2026 23:43:49 +0100 Subject: [PATCH] fix: fall back to application/octet-stream when the file has no mime type stored --- pkg/routes/api/v1/task_attachment.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/routes/api/v1/task_attachment.go b/pkg/routes/api/v1/task_attachment.go index 8a832602e..5be5a2132 100644 --- a/pkg/routes/api/v1/task_attachment.go +++ b/pkg/routes/api/v1/task_attachment.go @@ -204,8 +204,14 @@ func GetTaskAttachment(c *echo.Context) error { _ = s.Rollback() return err } + + mimeToReturn := taskAttachment.File.Mime + if mimeToReturn == "" { + mimeToReturn = "application/octet-stream" + } + c.Response().Header().Set("Content-Disposition", "attachment; filename=\""+taskAttachment.File.Name+"\"") - c.Response().Header().Set("Content-Type", taskAttachment.File.Mime) + c.Response().Header().Set("Content-Type", mimeToReturn) c.Response().Header().Set("Content-Length", strconv.FormatUint(taskAttachment.File.Size, 10)) c.Response().Header().Set("Last-Modified", taskAttachment.File.Created.UTC().Format(http.TimeFormat))