mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-18 06:03:42 +08:00
🔖 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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user