mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
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:
@@ -204,13 +204,9 @@ func send(c *gin.Context, attachmentTmpDir string, signalCliConfig string, numbe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fType, err := filetype.Get(dec)
|
mimeType := mimetype.Detect(dec)
|
||||||
if err != nil {
|
|
||||||
c.JSON(400, gin.H{"error": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
attachmentTmpPath := attachmentTmpDir + u.String() + "." + fType.Extension
|
attachmentTmpPath := attachmentTmpDir + u.String() + "." + mimeType.Extension()
|
||||||
attachmentTmpPaths = append(attachmentTmpPaths, attachmentTmpPath)
|
attachmentTmpPaths = append(attachmentTmpPaths, attachmentTmpPath)
|
||||||
|
|
||||||
f, err := os.Create(attachmentTmpPath)
|
f, err := os.Create(attachmentTmpPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user