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
This commit is contained in:
Bernhard B
2021-05-25 23:06:40 +02:00
parent 6d39ac124f
commit d04beed5de

View File

@@ -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)