Exemple #1
0
        public HttpResponseMessage InfoPackage()
        {
            var tempFileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            try
            {
                using (var file = new FileStream(tempFileName, FileMode.Create))
                    using (var package = new ZipArchive(file, ZipArchiveMode.Create))
                    {
                        DebugInfoProvider.CreateInfoPackageForDatabase(package, Database, RequestManager);
                    }

                var response = new HttpResponseMessage();

                response.Content = new StreamContent(new FileStream(tempFileName, FileMode.Open, FileAccess.Read))
                {
                    Headers =
                    {
                        ContentDisposition = new ContentDispositionHeaderValue("attachment")
                        {
                            FileName       = string.Format("Debug-Info-{0}.zip",SystemTime.UtcNow),
                        },
                        ContentType        = new MediaTypeHeaderValue("application/octet-stream")
                    }
                };

                return(response);
            }
            finally
            {
                IOExtensions.DeleteFile(tempFileName);
            }
        }