From 2eba04b9da646fc96eb1942f8ceafa1e7d817dd8 Mon Sep 17 00:00:00 2001 From: Daniel Legt Date: Wed, 3 Jun 2026 15:31:18 +0300 Subject: [PATCH] fix(upload): sniff content type for application/octet-stream When an incoming file has an empty content type or is marked as "application/octet-stream", attempt to detect the actual MIME type by reading the first 512 bytes of the file. This improves content type accuracy for generic binary uploads. --- backend/libs/services/upload.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/libs/services/upload.go b/backend/libs/services/upload.go index 94e9eaf..e7bce12 100644 --- a/backend/libs/services/upload.go +++ b/backend/libs/services/upload.go @@ -397,7 +397,7 @@ func (s *UploadService) writeIncomingFilesToBox(ctx context.Context, box *Box, f storedName := "@each@" + fileID + strings.ToLower(filepath.Ext(incoming.Name())) objectKey := boxObjectKey(box.ID, storedName) contentType := incoming.ContentType() - if contentType == "" { + if contentType == "" || contentType == "application/octet-stream" { buffer := make([]byte, 512) n, _ := file.Read(buffer) contentType = http.DetectContentType(buffer[:n])