mirror of https://gitee.com/answerdev/answer.git
fix(image): support upload jog images
This commit is contained in:
parent
7a6acc5967
commit
541c35e827
|
@ -12,13 +12,15 @@ func IsSupportedImageFile(file io.Reader, ext string) bool {
|
||||||
ext = strings.TrimPrefix(ext, ".")
|
ext = strings.TrimPrefix(ext, ".")
|
||||||
var err error
|
var err error
|
||||||
switch strings.ToUpper(ext) {
|
switch strings.ToUpper(ext) {
|
||||||
case "JPG", "JPEG":
|
case "JPEG":
|
||||||
_, err = jpeg.Decode(file)
|
_, err = jpeg.Decode(file)
|
||||||
case "PNG":
|
case "PNG":
|
||||||
_, err = png.Decode(file)
|
_, err = png.Decode(file)
|
||||||
case "ICO":
|
case "ICO":
|
||||||
// TODO: There is currently no good Golang library to parse whether the image is in ico format.
|
// TODO: There is currently no good Golang library to parse whether the image is in ico format.
|
||||||
return true
|
return true
|
||||||
|
case "JPG":
|
||||||
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue