From d04beed5de89256a89a770790d77879a3478637f Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Tue, 25 May 2021 23:06:40 +0200 Subject: [PATCH] replaced h2non/filedetect with gabriel-vasile/mimetype library * the mimetype library is faster and correctly detects text files as text/plain. (the filedetect library classified them as binary files) see #136 --- src/api/api.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/api/api.go b/src/api/api.go index 1f9bc24..3a0f774 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -204,13 +204,9 @@ func send(c *gin.Context, attachmentTmpDir string, signalCliConfig string, numbe return } - fType, err := filetype.Get(dec) - if err != nil { - c.JSON(400, gin.H{"error": err.Error()}) - return - } + mimeType := mimetype.Detect(dec) - attachmentTmpPath := attachmentTmpDir + u.String() + "." + fType.Extension + attachmentTmpPath := attachmentTmpDir + u.String() + "." + mimeType.Extension() attachmentTmpPaths = append(attachmentTmpPaths, attachmentTmpPath) f, err := os.Create(attachmentTmpPath)