limit the maximum size of upload pictures

This commit is contained in:
MaysWind
2024-09-06 23:34:35 +08:00
parent 2dddb77ca4
commit 9622d5de06
8 changed files with 30 additions and 0 deletions
+5
View File
@@ -544,6 +544,11 @@ func (a *UsersApi) UserUpdateAvatarHandler(c *core.WebContext) (any, *errs.Error
return nil, errs.ErrUserAvatarIsEmpty
}
if avatarFiles[0].Size > int64(a.CurrentConfig().MaxAvatarFileSize) {
log.Warnf(c, "[users.UserUpdateAvatarHandler] the upload file size \"%d\" exceeds the maximum size \"%d\" of user avatar for user \"uid:%d\"", avatarFiles[0].Size, a.CurrentConfig().MaxAvatarFileSize, uid)
return nil, errs.ErrExceedMaxUserAvatarFileSize
}
fileExtension := utils.GetFileNameExtension(avatarFiles[0].Filename)
if utils.GetImageContentType(fileExtension) == "" {