Uploading the same media file two times in the Upload Media dialog of the Content Editor might result in an empty client-side error and the following error in the log records:
Exception: Sitecore.Exceptions.DuplicateItemNameException
Message: The item name "your_image" 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)
The issue appears when uploading a file with the name which already exists in the same folder and it does not happen with admin user.
Consider the following solutions:
if (errorThrown === "abort") {
that.app.trigger("upload-error", { id: data.__id });
} else {
if (!errorThrown || errorThrown.trim() === '')
{
errorThrown = jqXHR.responseJSON.errorItems[0].Message.concat(" See logs for more details.")
}
var errors = [{ Message: errorThrown }];
that.app.trigger("sc-error", errors);
that.app.trigger("upload-error", { id: data.__id, errors: errors });
}