I store user uploaded files in Media Library, which can later be downloaded by admins. When saving files, I change the file names to guarantee uniqueness, but later when admins download them I want them to see the original or user friendly file name.
This is the line of code behind the download button:
HttpContext.Current.Response.Redirect(MediaManager.GetMediaUrl(mediaItem));
Sitecore uses media item name and the extension stored in Extension
property to construct the default file name. It does not use the display name, nor the title or any other field.
I know that the file name is reflected in the content-disposition
header and looks like attachment;FileName.doc
. I want to know if there is any way I can modify that header in the response of the file download so I can have a chance to include my own logic.
I know, I can create my own custom download handler, but my specific question is regarding intercepting media download requests in Sitecore, which is the preferable method.