Friday 23 May 2014

Downloading Large files from Windows Azure

 





//Retrieve filenname from DB (based on fileid (Guid))
// *SNIP*
string filename = "Dinesh.txt";


if (HttpContext.Current.Request.UserAgent != null &&
HttpContext.Current.Request.UserAgent.ToUpper().Contains("MSIE"))
    filename = HttpUtility.UrlEncode(filename,
 System.Text.Encoding.UTF8).Replace("+", " ");

context.Response.Charset = "UTF-8";

context.Response.Buffer = false;
context.Response.AddHeader("Content-Disposition",
 "attachment; filename=\"" + filename + "\"");
context.Response.AddHeader("Content-Length", "100122334");
//Set the length the file
context.Response.ContentType = "application/octet-stream";
context.Response.Flush();

//Use the Azure API to stream the blob to the user instantly.
// *SNIP*
fileBlob.DownloadToStream(context.Response.OutputStream);

Hide New... button on lookup controls in model-driven apps

  The 'New ...' button is shown upon opening the lookup search dialog whenever the logged in user has at least user create privileg...