using System; using System.Collections.Generic; using System.Linq; using System.Security; using System.Security.Claims; using System.Threading; using System.Web; namespace Neo.LegitimateLicences.Api { /// /// Summary description for BlobDownload /// public class BlobDownload : IHttpHandler { public void ProcessRequest(HttpContext context) { ////#region Check security //todo re-enable!!!! ////var currentUser = (ClaimsIdentity)Thread.CurrentPrincipal.Identity; ////if (currentUser != null) ////{ //// var userClaim = currentUser.Claims.Where(a => a.Type == "UserID").FirstOrDefault(); //// var companyClaim = currentUser.Claims.Where(a => a.Type == "CompanyDetailID").FirstOrDefault(); //// if (userClaim == null || companyClaim == null) //// { //// throw new Exception("Security error downloading file"); //// } ////} ////else ////{ //// throw new Exception("Security error downloading file"); ////} ////#endregion var targetContainer = ""; if (context.Request.QueryString["targetContainer"] != null) { targetContainer = context.Request.QueryString["targetContainer"]; } var file = context.Request.QueryString["file"]; ////var bs = new BlobStorage(targetContainer); ////var fileBlob = bs.DownloadFile(file); ////var fileName = fileBlob.FullName; ////if (context.Request.QueryString["fileName"] != null) ////{ //// fileName = context.Request.QueryString["fileName"].ToString(); ////} ////var clientFileName = fileBlob.Name; ////if (!String.IsNullOrEmpty(clientFileName)) ////{ //// fileName = clientFileName; ////} ////context.Response.ClearHeaders(); ////context.Response.ClearContent(); ////context.Response.AddHeader("Content-Disposition", " attachment; filename=" + fileName); ////context.Response.SetCookie(new HttpCookie("fileExport", "true") { Path = "/" }); ////context.Response.AddHeader("Content-Length", fileBlob.Content.Length.ToString()); ////context.Response.ContentType = fileBlob.MimeType; ////context.Response.Charset = "UTF-8"; ////context.Response.BinaryWrite(fileBlob.Content); context.Response.Flush(); context.Response.Clear(); } public bool IsReusable { get { return false; } } } }