Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"errors"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -421,8 +422,16 @@ func (a *ApplicationAPI) UploadApplicationImage(ctx *gin.Context) {
return
}
head := make([]byte, 261)
open, _ := file.Open()
open.Read(head)
open, err := file.Open()
if err != nil {
ctx.AbortWithError(500, err)
return
}
defer open.Close()
if _, err := open.Read(head); err != nil && err != io.EOF {
ctx.AbortWithError(500, err)
return
}
if !filetype.IsImage(head) {
ctx.AbortWithError(400, errors.New("file must be an image"))
return
Expand Down
Loading