Fixed serverside errors occurring when getting files with no extension

This commit is contained in:
hmhealey
2016-01-25 09:43:40 -05:00
parent 93a4e85c2d
commit 1cd25cf380
2 changed files with 24 additions and 5 deletions

View File

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