diff options
author | =Corey Hulen <corey@hulen.com> | 2016-01-25 11:23:55 -0500 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-01-25 11:23:55 -0500 |
commit | ea71731f838fc010cfc7511c09875184d1b2396b (patch) | |
tree | 7841e6908a42badb5171760426d2ca5898a76bda /model/file_info.go | |
parent | 6b534f1b0dae2614ec267a82f1c4dc1b096b7b1c (diff) | |
parent | 5478ea34e436109ece417c3704a1fa36d3aba4a5 (diff) | |
download | chat-ea71731f838fc010cfc7511c09875184d1b2396b.tar.gz chat-ea71731f838fc010cfc7511c09875184d1b2396b.tar.bz2 chat-ea71731f838fc010cfc7511c09875184d1b2396b.zip |
merging
Diffstat (limited to 'model/file_info.go')
-rw-r--r-- | model/file_info.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/model/file_info.go b/model/file_info.go index 741b4e55d..f785042b3 100644 --- a/model/file_info.go +++ b/model/file_info.go @@ -32,11 +32,16 @@ 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 if gifImage, err := gif.DecodeAll(bytes.NewReader(data)); err != nil { - return nil, NewAppError("GetInfoForBytes", "Could not decode gif.", "filename="+filename) + return nil, NewLocAppError("GetInfoForBytes", "model.file_info.get.gif.app_error", nil, "filename="+filename) } else { hasPreviewImage = len(gifImage.Image) == 1 } @@ -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 |