mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
limit the maximum size of upload pictures
This commit is contained in:
@@ -55,6 +55,11 @@ func (a *TransactionPicturesApi) TransactionPictureUploadHandler(c *core.WebCont
|
||||
return nil, errs.ErrTransactionPictureIsEmpty
|
||||
}
|
||||
|
||||
if pictureFiles[0].Size > int64(a.CurrentConfig().MaxTransactionPictureFileSize) {
|
||||
log.Warnf(c, "[transaction_pictures.TransactionPictureUploadHandler] the upload file size \"%d\" exceeds the maximum size \"%d\" of transaction picture for user \"uid:%d\"", pictureFiles[0].Size, a.CurrentConfig().MaxTransactionPictureFileSize, uid)
|
||||
return nil, errs.ErrExceedMaxTransactionPictureFileSize
|
||||
}
|
||||
|
||||
fileExtension := utils.GetFileNameExtension(pictureFiles[0].Filename)
|
||||
|
||||
if utils.GetImageContentType(fileExtension) == "" {
|
||||
|
||||
@@ -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) == "" {
|
||||
|
||||
Reference in New Issue
Block a user