Monday 15 May 2017

Same filename but different extensions are not download in sitecore

I have used sitecore 8.1 version. recently and i have faced one issue that if in media library have duplicate item name but extension was different, it was not download both file.
Please see below items of as example:
  1. ROI.pdf
  2. ROI.docx
But when i was clicked on ROI.Pdf in my website for download or watch it was ROI.Docx downloaded. because of in sitecore media library section first file store as ROI.Docx and then second file store as ROI.pdf so sitecore find name wise item and not consider extension.  i have used below link for download.
  1. /~/media/ROI.docx
  2. /~/media/ROI.pdf
Solution:-

The problem is that both media items have the same name, which is not recommended by sitecore. When you access the item with a direct link the media handler does not take into account the .pdf extension. It uses only the item path. Because of this it may return unexpected results when you have items with same names on one level.
 
You have 3 options to fix this issue: 
 
1. Move items to different folders.
 
2. You can create items with different names for different file types. If you enable the Media.IncludeExtensionsInItemNames setting in sitecore.config, the file extension will be included automatically in the item name when you upload it to the Media Library.
 
3. You can disable the Media.UseItemPaths setting in sitecore.config. After this Sitecore will create links to media items using their IDs, not the full path: 
 For Example:
<a href="~/media/4A9EA5A5A7214B2182DE1085B3EB7284.ashx">.
 
Might be its helpful to you, Keep smile and keep coding :) 

No comments:

Post a Comment