I tried to download a media item from media library to my local storage using the Item ID. But it downloaded only in cache storage. I want to download it in downloads folder.
public void downloadform(string fileid)
{
var mediaItem =Database.GetDatabase("master").GetItem(new ID(fileid));
var media = Sitecore.Resources.Media.MediaManager.GetMedia(mediaItem);
//Get Media Stream in buffer
var mediaStream = media.GetStream();
byte[] buffer = new byte[(int)mediaStream.Length];
mediaStream.Stream.Read(buffer, 0, (int)mediaStream.Length);
//Send response to browser
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", buffer.Length.ToString());
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + mediaItem.Name + ".pdf");
System.Web.HttpContext.Current.Response.BinaryWrite(buffer);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}