From 40d018c52664a629752dc8d5db72094b6195fd65 Mon Sep 17 00:00:00 2001 From: Stephen Cleary Date: Sat, 15 Oct 2016 16:02:31 -0400 Subject: [PATCH 1/2] Rename and readme. --- .../Example.sln | 0 .../WebApplication/App_Start/WebApiConfig.cs | 0 .../WebApplication/Controllers/FileController.cs | 0 .../WebApplication/Global.asax | 0 .../WebApplication/Global.asax.cs | 0 .../WebApplication/Web.Debug.config | 0 .../WebApplication/Web.Release.config | 0 .../WebApplication/Web.config | 0 .../WebApplication/WebApplication.csproj | 0 .../WebApplication/packages.config | 0 README.md | 11 +++++++++-- 11 files changed, 9 insertions(+), 2 deletions(-) rename AsyncPushStreamContentExample/AsyncPushStreamContentExample.sln => Example/Example.sln (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/App_Start/WebApiConfig.cs (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/Controllers/FileController.cs (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/Global.asax (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/Global.asax.cs (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/Web.Debug.config (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/Web.Release.config (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/Web.config (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/WebApplication.csproj (100%) rename {AsyncPushStreamContentExample => Example}/WebApplication/packages.config (100%) diff --git a/AsyncPushStreamContentExample/AsyncPushStreamContentExample.sln b/Example/Example.sln similarity index 100% rename from AsyncPushStreamContentExample/AsyncPushStreamContentExample.sln rename to Example/Example.sln diff --git a/AsyncPushStreamContentExample/WebApplication/App_Start/WebApiConfig.cs b/Example/WebApplication/App_Start/WebApiConfig.cs similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/App_Start/WebApiConfig.cs rename to Example/WebApplication/App_Start/WebApiConfig.cs diff --git a/AsyncPushStreamContentExample/WebApplication/Controllers/FileController.cs b/Example/WebApplication/Controllers/FileController.cs similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/Controllers/FileController.cs rename to Example/WebApplication/Controllers/FileController.cs diff --git a/AsyncPushStreamContentExample/WebApplication/Global.asax b/Example/WebApplication/Global.asax similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/Global.asax rename to Example/WebApplication/Global.asax diff --git a/AsyncPushStreamContentExample/WebApplication/Global.asax.cs b/Example/WebApplication/Global.asax.cs similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/Global.asax.cs rename to Example/WebApplication/Global.asax.cs diff --git a/AsyncPushStreamContentExample/WebApplication/Web.Debug.config b/Example/WebApplication/Web.Debug.config similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/Web.Debug.config rename to Example/WebApplication/Web.Debug.config diff --git a/AsyncPushStreamContentExample/WebApplication/Web.Release.config b/Example/WebApplication/Web.Release.config similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/Web.Release.config rename to Example/WebApplication/Web.Release.config diff --git a/AsyncPushStreamContentExample/WebApplication/Web.config b/Example/WebApplication/Web.config similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/Web.config rename to Example/WebApplication/Web.config diff --git a/AsyncPushStreamContentExample/WebApplication/WebApplication.csproj b/Example/WebApplication/WebApplication.csproj similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/WebApplication.csproj rename to Example/WebApplication/WebApplication.csproj diff --git a/AsyncPushStreamContentExample/WebApplication/packages.config b/Example/WebApplication/packages.config similarity index 100% rename from AsyncPushStreamContentExample/WebApplication/packages.config rename to Example/WebApplication/packages.config diff --git a/README.md b/README.md index 52266a5..4e7a273 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ -# AsyncPushStreamContent -Example of asynchronous usage of `PushStreamContent`. +# Async Zip-on-the-Fly + +Example of dynamically generating a zip file download from ASP.NET WebAPI, with minimal threading and memory usage. + +Specifically, with this code: +- No file is ever completely in memory at any time. As files are read, they are immediately compressed and sent to the browser. +- No threads are ever blocked waiting on reads or writes. The fully-asynchronous code permits threads to return to the thread pool unless they are actually executing code. + +This example uses `PushStreamContent` (with an asynchronous delegate), and uses `DotNetZip` to create the zip stream. \ No newline at end of file From a3fa19080efc5638c312031a3d25cde1b1d07a6e Mon Sep 17 00:00:00 2001 From: Stephen Cleary Date: Thu, 20 Oct 2016 12:08:53 -0400 Subject: [PATCH 2/2] Fix file references. --- Example/WebApplication/Controllers/FileController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/WebApplication/Controllers/FileController.cs b/Example/WebApplication/Controllers/FileController.cs index b2fde28..37dfe32 100644 --- a/Example/WebApplication/Controllers/FileController.cs +++ b/Example/WebApplication/Controllers/FileController.cs @@ -19,8 +19,8 @@ public HttpResponseMessage Get() { var filenamesAndUrls = new Dictionary { - { "README.md", "https://raw.githubusercontent.com/StephenClearyExamples/AsyncPushStreamContent/master/README.md" }, - { ".gitignore", "https://raw.githubusercontent.com/StephenClearyExamples/AsyncPushStreamContent/master/.gitignore" }, + { "README.md", "https://raw.githubusercontent.com/StephenClearyExamples/AsyncDynamicZip/master/README.md" }, + { ".gitignore", "https://raw.githubusercontent.com/StephenClearyExamples/AsyncDynamicZip/master/.gitignore" }, }; var result = new HttpResponseMessage(HttpStatusCode.OK)