If a content author uploads a media item in a folder which has an item with same name, then Upload File dialog will throw an error. "An error occured while uploading a file. The reason may be that the file does not exist or the path is wrong.". This is not a meaningful error to the content authors.
1984 14:44:04 ERROR Could not save posted file: Related Items.png
Exception: Sitecore.Exceptions.DuplicateItemNameException
Message: The item name "Related Items" is already defined on this level.
Source: Sitecore.Kernel
at Sitecore.Data.Items.ItemUtil.AssertDuplicateItemName(Item destinationItem, Item sourceItem, String name)
at Sitecore.Data.Items.ItemUtil.AssertItemName(Item destinationItem, Item sourceItem, String name)
at Sitecore.Data.Items.Item.Add(String name, TemplateID templateID)
at Sitecore.Resources.Media.MediaCreator.CreateItem(String itemPath, String filePath, MediaCreatorOptions options)
at Sitecore.Resources.Media.MediaCreator.AttachStreamToMediaItem(Stream stream, String itemPath, String fileName, MediaCreatorOptions options)
at Sitecore.Resources.Media.MediaCreator.CreateFromStream(Stream stream, String filePath, MediaCreatorOptions options)
at Sitecore.Resources.Media.MediaUploader.UploadToDatabase(List`1 list)
at Sitecore.Resources.Media.MediaUploader.Upload()
at Sitecore.Pipelines.Upload.Save.Process(UploadArgs args)
In order to provide content author with meaningful error message, you can overwrite the Upload Media dialog and render a meaning error message. sitecore.shell.Applications.Media.UploadMedia.UploadMediaPage2 Dialog has to be modified. Sample code is placed in this repo.
How is the .cs compiled and how is it referenced? Do we need to add a pipeline config?
ReplyDelete.cs can be compiled and added it in your project. ASPX should be updated with your project namespace.
ReplyDelete