diff --git a/src/Orchard.Web/Modules/Orchard.Media/Services/IMediaService.cs b/src/Orchard.Web/Modules/Orchard.Media/Services/IMediaService.cs
index cf3c49581..957199e38 100644
--- a/src/Orchard.Web/Modules/Orchard.Media/Services/IMediaService.cs
+++ b/src/Orchard.Web/Modules/Orchard.Media/Services/IMediaService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
@@ -92,5 +93,20 @@ namespace Orchard.Media.Services {
/// Boolean value indicating weather zip files should be extracted.
/// The path to the uploaded file.
string UploadMediaFile(string folderPath, string fileName, Stream inputStream, bool extractZip);
+
+ ///
+ /// Verifies if a file is allowed based on its name and the policies defined by the black / white lists.
+ ///
+ /// The posted file
+ /// True if the file is allowed; false if otherwise.
+ bool FileAllowed(HttpPostedFileBase postedFile);
+
+ ///
+ /// Verifies if a file is allowed based on its name and the policies defined by the black / white lists.
+ ///
+ /// The file name of the file to validate.
+ /// Boolean value indicating weather zip files are allowed.
+ /// True if the file is allowed; false if otherwise.
+ bool FileAllowed(string fileName, bool allowZip);
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Media/Services/MediaService.cs b/src/Orchard.Web/Modules/Orchard.Media/Services/MediaService.cs
index 78d784502..fe6d77ea7 100644
--- a/src/Orchard.Web/Modules/Orchard.Media/Services/MediaService.cs
+++ b/src/Orchard.Web/Modules/Orchard.Media/Services/MediaService.cs
@@ -209,13 +209,26 @@ namespace Orchard.Media.Services {
return _storageProvider.GetPublicUrl(filePath);
}
+ ///
+ /// Verifies if a file is allowed based on its name and the policies defined by the black / white lists.
+ ///
+ /// The posted file
+ /// True if the file is allowed; false if otherwise.
+ public bool FileAllowed(HttpPostedFileBase postedFile) {
+ if (postedFile == null) {
+ return false;
+ }
+
+ return FileAllowed(postedFile.FileName, true);
+ }
+
///
/// Verifies if a file is allowed based on its name and the policies defined by the black / white lists.
///
/// The file name of the file to validate.
/// Boolean value indicating weather zip files are allowed.
/// True if the file is allowed; false if otherwise.
- protected bool FileAllowed(string fileName, bool allowZip) {
+ public bool FileAllowed(string fileName, bool allowZip) {
string localFileName = GetFileName(fileName);
string extension = GetExtension(localFileName);
if (string.IsNullOrEmpty(localFileName) || string.IsNullOrEmpty(extension)) {