public static bool IsAllowedFile(string fileName, long fileSize) { var fileConfigs = MediaPluginRepository.GetMediaFileConfig(); var fileAllowed = fileConfigs.SingleOrDefault(k => k.Extension == fileName.FileExtensionWithoutDot()); return(!(fileSize > System.Convert.ToDouble(fileAllowed?.SizeAllowed))); }
public static bool IsAllowedFile(HttpPostedFileBase file) { var fileConfigs = MediaPluginRepository.GetMediaFileConfig(); double fileSize = file.ContentLength.ConvertBytesToMegabytes(); var fileAllowed = fileConfigs.SingleOrDefault(k => k.Extension == file.FileName.FileExtensionWithoutDot()); return(!(fileSize > System.Convert.ToDouble(fileAllowed?.SizeAllowed))); }
public static bool CheckRestrictedFileType(string fileName) { MediaPluginRepository mediaConfig = new MediaPluginRepository(); var fileConfigs = MediaPluginRepository.GetMediaFileConfig(); var fileAllowed = fileConfigs.SingleOrDefault(k => k.Extension == fileName.FileExtensionWithoutDot()); return(fileAllowed == null); }
public static int RestrictedFileSize(string fileName) { MediaPluginRepository mediaConfig = new MediaPluginRepository(); var fileConfigs = MediaPluginRepository.GetMediaFileConfig(); var fileAllowed = fileConfigs.SingleOrDefault(k => k.Extension == fileName.FileExtensionWithoutDot()); if (fileAllowed == null) { return(0); } return(fileAllowed.SizeAllowed); }