Exemple #1
0
 public static IRuleBuilderOptions <T, TProperty> AllowedFileExtension <T, TProperty>(this IRuleBuilder <T, TProperty> ruleBuilder, AllowedExtensionsOptions options) where TProperty : IFormFile
 {
     return(ruleBuilder
            .Must(x => !string.IsNullOrEmpty(x.FileName))
            .Must(x => options.Extensions.Contains(x.FileName.Split('.').LastOrDefault()))
            .WithMessage($"Filename empty or Forbidden file extension. Allowed extension: {string.Join(", ", options.Extensions)}"));
 }
Exemple #2
0
 public FileHelper(IOptions <AllowedExtensionsOptions> options)
 {
     _options = options.Value;
 }