30 lines
908 B
C#
30 lines
908 B
C#
//using Microsoft.AspNetCore.Http;
|
|
//using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
|
//using System.ComponentModel.DataAnnotations;
|
|
|
|
//namespace _0_Framework.Application
|
|
//{
|
|
// public class MaxFileSizeAttribute : ValidationAttribute, IClientModelValidator
|
|
// {
|
|
// private readonly int _maxFileSize;
|
|
|
|
// public MaxFileSizeAttribute(int maxFileSize)
|
|
// {
|
|
// _maxFileSize = maxFileSize;
|
|
// }
|
|
|
|
// public override bool IsValid(object value)
|
|
// {
|
|
// var file = value as IFormFile;
|
|
// if (file == null) return true;
|
|
// return file.Length <= _maxFileSize;
|
|
// }
|
|
|
|
// public void AddValidation(ClientModelValidationContext context)
|
|
// {
|
|
// context.Attributes.Add("data-val", "true");
|
|
// context.Attributes.Add("data-val-maxFileSize", ErrorMessage);
|
|
// }
|
|
// }
|
|
//}
|