🔖 chore: Added File Type Check for Image Size Retrieval

* optimized the log content of uploaded files is too large

* optimized the log content of uploaded files is too large

* optimize GetImageSize
This commit is contained in:
Clivia
2024-05-27 14:25:33 +08:00
committed by GitHub
parent 0f658c5a53
commit 02a9087b9a
2 changed files with 8 additions and 3 deletions

View File

@@ -111,8 +111,12 @@ func GetImageSizeFromBase64(encoded string) (width int, height int, err error) {
}
func GetImageSize(image string) (width int, height int, err error) {
if strings.HasPrefix(image, "data:image/") {
switch {
case strings.HasPrefix(image, "data:image/"):
return GetImageSizeFromBase64(image)
case strings.HasPrefix(image, "http"):
return GetImageSizeFromUrl(image)
default:
return 0, 0, errors.New("invalid file type, Please view request interface!")
}
return GetImageSizeFromUrl(image)
}