mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-06-28 15:34:39 +08:00
Updating MediaLibrary not to log an error when a file can't be uploaded due to invalid characters
This commit is contained in:
parent
08ae5ddccf
commit
e43e3d9b55
@ -3,15 +3,14 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.FileSystems.Media;
|
||||||
|
using Orchard.Localization;
|
||||||
|
using Orchard.Logging;
|
||||||
|
using Orchard.MediaLibrary.Models;
|
||||||
using Orchard.MediaLibrary.Services;
|
using Orchard.MediaLibrary.Services;
|
||||||
using Orchard.MediaLibrary.ViewModels;
|
using Orchard.MediaLibrary.ViewModels;
|
||||||
using Orchard.Themes;
|
using Orchard.Themes;
|
||||||
using Orchard.UI.Admin;
|
using Orchard.UI.Admin;
|
||||||
using Orchard.MediaLibrary.Models;
|
|
||||||
using Orchard.Localization;
|
|
||||||
using System.Linq;
|
|
||||||
using Orchard.FileSystems.Media;
|
|
||||||
using Orchard.Logging;
|
|
||||||
|
|
||||||
namespace Orchard.MediaLibrary.Controllers {
|
namespace Orchard.MediaLibrary.Controllers {
|
||||||
[Admin, Themed(false)]
|
[Admin, Themed(false)]
|
||||||
@ -107,10 +106,16 @@ namespace Orchard.MediaLibrary.Controllers {
|
|||||||
url = mediaPart.FileName,
|
url = mediaPart.FileName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (InvalidNameCharacterException) {
|
||||||
Logger.Error(ex, "Unexpected exception when uploading a media.");
|
|
||||||
statuses.Add(new {
|
statuses.Add(new {
|
||||||
error = T(ex.Message).Text,
|
error = T("The file name contains invalid character(s)").Text,
|
||||||
|
progress = 1.0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, T("Unexpected exception when uploading a media.").Text);
|
||||||
|
statuses.Add(new {
|
||||||
|
error = ex.Message,
|
||||||
progress = 1.0,
|
progress = 1.0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -146,7 +151,8 @@ namespace Orchard.MediaLibrary.Controllers {
|
|||||||
var filename = Path.GetFileName(file.FileName);
|
var filename = Path.GetFileName(file.FileName);
|
||||||
|
|
||||||
// if the file has been pasted, provide a default name
|
// if the file has been pasted, provide a default name
|
||||||
if (file.ContentType.Equals("image/png", StringComparison.InvariantCultureIgnoreCase) && !filename.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) {
|
if (file.ContentType.Equals("image/png", StringComparison.InvariantCultureIgnoreCase)
|
||||||
|
&& !filename.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) {
|
||||||
filename = "clipboard.png";
|
filename = "clipboard.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +190,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Logger.Error(ex, "Unexpected exception when uploading a media.");
|
Logger.Error(ex, T("Unexpected exception when uploading a media.").Text);
|
||||||
|
|
||||||
statuses.Add(new {
|
statuses.Add(new {
|
||||||
error = T(ex.Message).Text,
|
error = T(ex.Message).Text,
|
||||||
|
Loading…
Reference in New Issue
Block a user