private static void Download(HttpContext context)
        {
            try
            {
                var fileName = Path.GetFileName(context.Request["filename"]);

                var filePath = DocManagerHelper.ForcesavePath(fileName, null, false);
                if (filePath.Equals(""))
                {
                    filePath = DocManagerHelper.StoragePath(fileName, null);
                }
                download(filePath, context);
            }
            catch (Exception)
            {
                context.Response.Write("{ \"error\": \"File not found!\"}");
            }
        }
        // download a file
        private static void Download(HttpContext context)
        {
            try
            {
                var fileName = Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ? context.Request["fileName"]
                    : Path.GetFileName(context.Request["fileName"]);
                var userAddress = context.Request["userAddress"];
                var isEmbedded  = context.Request["dmode"];

                if (JwtManager.Enabled && isEmbedded == null)
                {
                    string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];

                    if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
                    {
                        var    headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
                        string token       = JwtManager.Decode(headerToken);
                        if (token == null || token.Equals(""))
                        {
                            context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
                            context.Response.Write("JWT validation failed");
                            return;
                        }
                    }
                }

                var filePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false);  // get the path to the force saved document version
                if (filePath.Equals(""))
                {
                    filePath = DocManagerHelper.StoragePath(fileName, userAddress);  // or to the original document
                }
                download(filePath, context);
            }
            catch (Exception)
            {
                context.Response.Write("{ \"error\": \"File not found!\"}");
            }
        }