summaryrefslogtreecommitdiffstats
path: root/model/file_info.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/file_info.go')
-rw-r--r--model/file_info.go9
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