summaryrefslogtreecommitdiffstats
path: root/model/file_info.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2016-01-25 09:43:40 -0500
committerhmhealey <harrisonmhealey@gmail.com>2016-01-25 09:51:17 -0500
commit1cd25cf3806f6ceb2e47a3bc791569cedd0acf1d (patch)
treedfaa1acc75f089d58cdb4877dcdf9768197849be /model/file_info.go
parent93a4e85c2d183a48f84a269c38ad4b91e9c31c14 (diff)
downloadchat-1cd25cf3806f6ceb2e47a3bc791569cedd0acf1d.tar.gz
chat-1cd25cf3806f6ceb2e47a3bc791569cedd0acf1d.tar.bz2
chat-1cd25cf3806f6ceb2e47a3bc791569cedd0acf1d.zip
Fixed serverside errors occurring when getting files with no extension
Diffstat (limited to 'model/file_info.go')
-rw-r--r--model/file_info.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/model/file_info.go b/model/file_info.go
index 131baff6d..f785042b3 100644
--- a/model/file_info.go
+++ b/model/file_info.go
@@ -32,6 +32,11 @@ func GetInfoForBytes(filename string, data []byte) (*FileInfo, *AppError) {
mimeType = mime.TypeByExtension(extension)
}
+ if extension != "" && extension[0] == '.' {
+ // the client expects a file extension without the leading period
+ extension = extension[1:]
+ }
+
hasPreviewImage := isImage
if mimeType == "image/gif" {
// just show the gif itself instead of a preview image for animated gifs
@@ -45,7 +50,7 @@ func GetInfoForBytes(filename string, data []byte) (*FileInfo, *AppError) {
return &FileInfo{
Filename: filename,
Size: size,
- Extension: extension[1:],
+ Extension: extension,
MimeType: mimeType,
HasPreviewImage: hasPreviewImage,
}, nil