Fixing #17489: Authenticated user uploading the not allowed media donesn't have any error info [4569 (6cb6b7704f7c)]

--HG--
branch : 1.x
This commit is contained in:
Suha Can
2011-03-30 15:57:53 -07:00
parent 5ed02227d3
commit 104fc0219d
2 changed files with 9 additions and 6 deletions

View File

@@ -198,7 +198,7 @@ namespace Orchard.Media.Controllers {
Services.Notifier.Information(T("Media file(s) uploaded")); Services.Notifier.Information(T("Media file(s) uploaded"));
return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath }); return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
} catch (Exception exception) { } catch (Exception exception) {
this.Error(exception, T("Uploading media file failed: {0}", exception.Message), Logger, Services.Notifier); this.Error(exception, T("Uploading media file failed:"), Logger, Services.Notifier);
return View(viewModel); return View(viewModel);
} }

View File

@@ -196,14 +196,17 @@ namespace Orchard.Media.Services {
return _storageProvider.GetPublicUrl(folderPath); return _storageProvider.GetPublicUrl(folderPath);
} }
if (FileAllowed(fileName, true)) { if (!FileAllowed(fileName, true)) {
string filePath = _storageProvider.Combine(folderPath, fileName); var currentSite = _orchardServices.WorkContext.CurrentSite;
_storageProvider.SaveStream(filePath, inputStream); var mediaSettings = currentSite.As<MediaSettingsPart>();
return _storageProvider.GetPublicUrl(filePath); throw new ArgumentException(T("Could not upload file {0}. Supported file types are {1}.", fileName, mediaSettings.UploadAllowedFileTypeWhitelist).Text);
} }
return null; string filePath = _storageProvider.Combine(folderPath, fileName);
_storageProvider.SaveStream(filePath, inputStream);
return _storageProvider.GetPublicUrl(filePath);
} }
/// <summary> /// <summary>