├── .gitattributes ├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── WebApiFileUpload.API ├── App_Start │ ├── RouteConfig.cs │ └── WebApiConfig.cs ├── Controllers │ ├── FileUploadController.cs │ └── HomeController.cs ├── Global.asax ├── Global.asax.cs ├── Infrastructure │ ├── FileUploadResult.cs │ ├── MimeMultipart.cs │ └── UploadMultipartFormProvider.cs ├── Properties │ └── AssemblyInfo.cs ├── Scripts │ ├── angular-file-upload-shim.js │ ├── angular-file-upload.js │ ├── angular-route.js │ ├── angular.js │ └── jquery-1.8.2.js ├── Styles │ └── bootstrap.css ├── Views │ ├── Home │ │ └── Index.cshtml │ └── web.config ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── WebApiFileUpload.API.csproj ├── app │ ├── app.js │ ├── controllers │ │ └── fileUploadCtrl.js │ └── templates │ │ └── fileUpload.html └── packages.config ├── WebApiFileUpload.DesktopClient ├── App.config ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── WebApiFileUpload.DesktopClient.csproj └── packages.config ├── WebApiFileUpload.sln ├── licence └── packages └── repositories.config /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | [Bb]in/ 16 | [Oo]bj/ 17 | 18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 19 | !packages/*/build/ 20 | 21 | # MSTest test Results 22 | [Tt]est[Rr]esult*/ 23 | [Bb]uild[Ll]og.* 24 | 25 | *_i.c 26 | *_p.c 27 | *.ilk 28 | *.meta 29 | *.obj 30 | *.pch 31 | *.pdb 32 | *.pgc 33 | *.pgd 34 | *.rsp 35 | *.sbr 36 | *.tlb 37 | *.tli 38 | *.tlh 39 | *.tmp 40 | *.tmp_proj 41 | *.log 42 | *.vspscc 43 | *.vssscc 44 | .builds 45 | *.pidb 46 | *.log 47 | *.scc 48 | 49 | # Visual C++ cache files 50 | ipch/ 51 | *.aps 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | 57 | # Visual Studio profiler 58 | *.psess 59 | *.vsp 60 | *.vspx 61 | 62 | # Guidance Automation Toolkit 63 | *.gpState 64 | 65 | # ReSharper is a .NET coding add-in 66 | _ReSharper*/ 67 | *.[Rr]e[Ss]harper 68 | 69 | # TeamCity is a build add-in 70 | _TeamCity* 71 | 72 | # DotCover is a Code Coverage Tool 73 | *.dotCover 74 | 75 | # NCrunch 76 | *.ncrunch* 77 | .*crunch*.local.xml 78 | 79 | # Installshield output folder 80 | [Ee]xpress/ 81 | 82 | # DocProject is a documentation generator add-in 83 | DocProject/buildhelp/ 84 | DocProject/Help/*.HxT 85 | DocProject/Help/*.HxC 86 | DocProject/Help/*.hhc 87 | DocProject/Help/*.hhk 88 | DocProject/Help/*.hhp 89 | DocProject/Help/Html2 90 | DocProject/Help/html 91 | 92 | # Click-Once directory 93 | publish/ 94 | 95 | # Publish Web Output 96 | *.Publish.xml 97 | 98 | # NuGet Packages Directory 99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 100 | /packages/ 101 | !packages/repositories.config 102 | 103 | # Windows Azure Build Output 104 | csx 105 | *.build.csdef 106 | 107 | # Windows Store app package directory 108 | AppPackages/ 109 | 110 | # Others 111 | sql/ 112 | *.Cache 113 | ClientBin/ 114 | [Ss]tyle[Cc]op.* 115 | ~$* 116 | *~ 117 | *.dbmdl 118 | *.[Pp]ublish.xml 119 | *.pfx 120 | *.publishsettings 121 | 122 | # RIA/Silverlight projects 123 | Generated_Code/ 124 | 125 | # Backup & report files from converting an old project file to a newer 126 | # Visual Studio version. Backup files are not needed, because we have git ;-) 127 | _UpgradeReport_Files/ 128 | Backup*/ 129 | UpgradeLog*.XML 130 | UpgradeLog*.htm 131 | 132 | # SQL Server files 133 | App_Data/*.mdf 134 | App_Data/*.ldf 135 | 136 | 137 | #LightSwitch generated files 138 | GeneratedArtifacts/ 139 | _Pvt_Extensions/ 140 | ModelManifest.xml 141 | 142 | # ========================= 143 | # Windows detritus 144 | # ========================= 145 | 146 | # Windows image file caches 147 | Thumbs.db 148 | ehthumbs.db 149 | 150 | # Folder config file 151 | Desktop.ini 152 | 153 | # Recycle Bin used on file shares 154 | $RECYCLE.BIN/ 155 | 156 | # Mac desktop service store files 157 | .DS_Store 158 | -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chsakell/webapi-fileupload/a745adccb7ab945901e0b9006d61b0d5c3c61e6c/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 31 | 32 | 33 | 34 | 35 | $(SolutionDir).nuget 36 | 37 | 38 | 39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config 40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config 41 | 42 | 43 | 44 | $(MSBuildProjectDirectory)\packages.config 45 | $(PackagesProjectConfig) 46 | 47 | 48 | 49 | 50 | $(NuGetToolsPath)\NuGet.exe 51 | @(PackageSource) 52 | 53 | "$(NuGetExePath)" 54 | mono --runtime=v4.0.30319 "$(NuGetExePath)" 55 | 56 | $(TargetDir.Trim('\\')) 57 | 58 | -RequireConsent 59 | -NonInteractive 60 | 61 | "$(SolutionDir) " 62 | "$(SolutionDir)" 63 | 64 | 65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) 66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols 67 | 68 | 69 | 70 | RestorePackages; 71 | $(BuildDependsOn); 72 | 73 | 74 | 75 | 76 | $(BuildDependsOn); 77 | BuildPackage; 78 | 79 | 80 | 81 | 82 | 83 | 84 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 99 | 100 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace WebApiFileUpload.API 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Http; 5 | 6 | namespace WebApiFileUpload.API 7 | { 8 | public static class WebApiConfig 9 | { 10 | public static void Register(HttpConfiguration config) 11 | { 12 | // Web API configuration and services 13 | 14 | // Web API routes 15 | config.MapHttpAttributeRoutes(); 16 | 17 | config.Routes.MapHttpRoute( 18 | name: "DefaultApi", 19 | routeTemplate: "api/{controller}/{id}", 20 | defaults: new { id = RouteParameter.Optional } 21 | ); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Controllers/FileUploadController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Net.Http; 7 | using System.Threading.Tasks; 8 | using System.Web; 9 | using System.Web.Http; 10 | using WebApiFileUpload.API.Infrastructure; 11 | 12 | namespace WebApiFileUpload.API.Controllers 13 | { 14 | public class FileUploadController : ApiController 15 | { 16 | [MimeMultipart] 17 | public async Task Post() 18 | { 19 | var uploadPath = HttpContext.Current.Server.MapPath("~/Uploads"); 20 | 21 | var multipartFormDataStreamProvider = new UploadMultipartFormProvider(uploadPath); 22 | 23 | // Read the MIME multipart asynchronously 24 | await Request.Content.ReadAsMultipartAsync(multipartFormDataStreamProvider); 25 | 26 | string _localFileName = multipartFormDataStreamProvider 27 | .FileData.Select(multiPartData => multiPartData.LocalFileName).FirstOrDefault(); 28 | 29 | // Create response 30 | return new FileUploadResult 31 | { 32 | LocalFilePath = _localFileName, 33 | 34 | FileName = Path.GetFileName(_localFileName), 35 | 36 | FileLength = new FileInfo(_localFileName).Length 37 | }; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace WebApiFileUpload.API.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | // GET: Home 12 | public ActionResult Index() 13 | { 14 | return View(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /WebApiFileUpload.API/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="WebApiFileUpload.API.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | using System.Web.Security; 8 | using System.Web.SessionState; 9 | using System.Web.Http; 10 | 11 | namespace WebApiFileUpload.API 12 | { 13 | public class Global : HttpApplication 14 | { 15 | void Application_Start(object sender, EventArgs e) 16 | { 17 | // Code that runs on application startup 18 | AreaRegistration.RegisterAllAreas(); 19 | GlobalConfiguration.Configure(WebApiConfig.Register); 20 | RouteConfig.RegisterRoutes(RouteTable.Routes); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /WebApiFileUpload.API/Infrastructure/FileUploadResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace WebApiFileUpload.API.Infrastructure 7 | { 8 | public class FileUploadResult 9 | { 10 | public string LocalFilePath { get; set; } 11 | public string FileName { get; set; } 12 | public long FileLength { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /WebApiFileUpload.API/Infrastructure/MimeMultipart.cs: -------------------------------------------------------------------------------- 1 | #region Using 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Net.Http; 7 | using System.Web; 8 | using System.Web.Http; 9 | using System.Web.Http.Controllers; 10 | using System.Web.Http.Filters; 11 | #endregion 12 | 13 | namespace WebApiFileUpload.API.Infrastructure 14 | { 15 | public class MimeMultipart : ActionFilterAttribute 16 | { 17 | public override void OnActionExecuting(HttpActionContext actionContext) 18 | { 19 | if (!actionContext.Request.Content.IsMimeMultipartContent()) 20 | { 21 | throw new HttpResponseException( 22 | new HttpResponseMessage( 23 | HttpStatusCode.UnsupportedMediaType) 24 | ); 25 | } 26 | } 27 | 28 | public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) 29 | { 30 | 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /WebApiFileUpload.API/Infrastructure/UploadMultipartFormProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Net.Http.Headers; 6 | using System.Web; 7 | 8 | namespace WebApiFileUpload.API.Infrastructure 9 | { 10 | public class UploadMultipartFormProvider : MultipartFormDataStreamProvider 11 | { 12 | public UploadMultipartFormProvider(string rootPath) : base(rootPath) { } 13 | 14 | public override string GetLocalFileName(HttpContentHeaders headers) 15 | { 16 | if (headers != null && 17 | headers.ContentDisposition != null) 18 | { 19 | return headers 20 | .ContentDisposition 21 | .FileName.TrimEnd('"').TrimStart('"'); 22 | } 23 | 24 | return base.GetLocalFileName(headers); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /WebApiFileUpload.API/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("WebApiFileUpload.API")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WebApiFileUpload.API")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b9c7857f-76d3-4821-894d-1ff6e0b700c3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Scripts/angular-file-upload-shim.js: -------------------------------------------------------------------------------- 1 | /**! 2 | * AngularJS file upload shim for HTML5 FormData 3 | * @author Danial 4 | * @version 1.2.8 5 | */ 6 | (function() { 7 | 8 | if (window.XMLHttpRequest) { 9 | if (window.FormData) { 10 | // allow access to Angular XHR private field: https://github.com/angular/angular.js/issues/1934 11 | window.XMLHttpRequest = (function(origXHR) { 12 | return function() { 13 | var xhr = new origXHR(); 14 | xhr.setRequestHeader = (function(orig) { 15 | return function(header, value) { 16 | if (header === '__setXHR_') { 17 | var val = value(xhr); 18 | // fix for angular < 1.2.0 19 | if (val instanceof Function) { 20 | val(xhr); 21 | } 22 | } else { 23 | orig.apply(xhr, arguments); 24 | } 25 | } 26 | })(xhr.setRequestHeader); 27 | return xhr; 28 | } 29 | })(window.XMLHttpRequest); 30 | } else { 31 | var hasFlash = false; 32 | try { 33 | var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); 34 | if (fo) hasFlash = true; 35 | } catch(e) { 36 | if (navigator.mimeTypes["application/x-shockwave-flash"] != undefined) hasFlash = true; 37 | } 38 | window.XMLHttpRequest = (function(origXHR) { 39 | return function() { 40 | var xhr = new origXHR(); 41 | var origSend = xhr.send; 42 | xhr.__requestHeaders = []; 43 | xhr.open = (function(orig) { 44 | if (!xhr.upload) xhr.upload = {}; 45 | xhr.upload.addEventListener = function(t, fn, b) { 46 | if (t === 'progress') { 47 | xhr.__progress = fn; 48 | } 49 | if (t === 'load') { 50 | xhr.__load = fn; 51 | } 52 | }; 53 | return function(m, url, b) { 54 | orig.apply(xhr, [m, url, b]); 55 | xhr.__url = url; 56 | } 57 | })(xhr.open); 58 | xhr.getResponseHeader = (function(orig) { 59 | return function(h) { 60 | return xhr.__fileApiXHR ? xhr.__fileApiXHR.getResponseHeader(h) : orig.apply(xhr, [h]); 61 | } 62 | })(xhr.getResponseHeader); 63 | xhr.getAllResponseHeaders = (function(orig) { 64 | return function() { 65 | return xhr.__fileApiXHR ? xhr.__fileApiXHR.getAllResponseHeaders() : orig.apply(xhr); 66 | } 67 | })(xhr.getAllResponseHeaders); 68 | xhr.abort = (function(orig) { 69 | return function() { 70 | return xhr.__fileApiXHR ? xhr.__fileApiXHR.abort() : (orig == null ? null : orig.apply(xhr)); 71 | } 72 | })(xhr.abort); 73 | xhr.setRequestHeader = (function(orig) { 74 | return function(header, value) { 75 | if (header === '__setXHR_') { 76 | var val = value(xhr); 77 | // fix for angular < 1.2.0 78 | if (val instanceof Function) { 79 | val(xhr); 80 | } 81 | } else { 82 | orig.apply(xhr, arguments); 83 | } 84 | } 85 | })(xhr.setRequestHeader); 86 | 87 | xhr.send = function() { 88 | if (arguments[0] && arguments[0].__isShim) { 89 | var formData = arguments[0]; 90 | var config = { 91 | url: xhr.__url, 92 | complete: function(err, fileApiXHR) { 93 | if (!err) xhr.__load({type: 'load', loaded: xhr.__total, total: xhr.__total, target: xhr, lengthComputable: true}); 94 | if (fileApiXHR.status !== undefined) Object.defineProperty(xhr, 'status', {get: function() {return fileApiXHR.status}}); 95 | if (fileApiXHR.statusText !== undefined) Object.defineProperty(xhr, 'statusText', {get: function() {return fileApiXHR.statusText}}); 96 | Object.defineProperty(xhr, 'readyState', {get: function() {return 4}}); 97 | if (fileApiXHR.response !== undefined) Object.defineProperty(xhr, 'response', {get: function() {return fileApiXHR.response}}); 98 | Object.defineProperty(xhr, 'responseText', {get: function() {return fileApiXHR.responseText}}); 99 | xhr.__fileApiXHR = fileApiXHR; 100 | xhr.onreadystatechange(); 101 | }, 102 | progress: function(e) { 103 | e.target = xhr; 104 | xhr.__progress(e); 105 | xhr.__total = e.total; 106 | }, 107 | headers: xhr.__requestHeaders 108 | } 109 | config.data = {}; 110 | config.files = {} 111 | for (var i = 0; i < formData.data.length; i++) { 112 | var item = formData.data[i]; 113 | if (item.val != null && item.val.name != null && item.val.size != null && item.val.type != null) { 114 | config.files[item.key] = item.val; 115 | } else { 116 | config.data[item.key] = item.val; 117 | } 118 | } 119 | 120 | setTimeout(function() { 121 | if (!hasFlash) { 122 | alert('Please install Adode Flash Player to upload files.'); 123 | } 124 | xhr.__fileApiXHR = FileAPI.upload(config); 125 | }, 1); 126 | } else { 127 | origSend.apply(xhr, arguments); 128 | } 129 | } 130 | return xhr; 131 | } 132 | })(window.XMLHttpRequest); 133 | window.XMLHttpRequest.__hasFlash = hasFlash; 134 | } 135 | window.XMLHttpRequest.__isShim = true; 136 | } 137 | 138 | if (!window.FormData) { 139 | var wrapFileApi = function(elem) { 140 | if (!elem.__isWrapped && (elem.getAttribute('ng-file-select') != null || elem.getAttribute('data-ng-file-select') != null)) { 141 | var wrap = document.createElement('div'); 142 | wrap.innerHTML = '
'; 143 | wrap = wrap.firstChild; 144 | var parent = elem.parentNode; 145 | parent.insertBefore(wrap, elem); 146 | parent.removeChild(elem); 147 | wrap.appendChild(elem); 148 | elem.__isWrapped = true; 149 | } 150 | }; 151 | var changeFnWrapper = function(fn) { 152 | return function(evt) { 153 | var files = FileAPI.getFiles(evt); 154 | if (!evt.target) { 155 | evt.target = {}; 156 | } 157 | evt.target.files = files; 158 | evt.target.files.item = function(i) { 159 | return evt.target.files[i] || null; 160 | } 161 | fn(evt); 162 | }; 163 | }; 164 | var isFileChange = function(elem, e) { 165 | return (e.toLowerCase() === 'change' || e.toLowerCase() === 'onchange') && elem.getAttribute('type') == 'file'; 166 | } 167 | if (HTMLInputElement.prototype.addEventListener) { 168 | HTMLInputElement.prototype.addEventListener = (function(origAddEventListener) { 169 | return function(e, fn, b, d) { 170 | if (isFileChange(this, e)) { 171 | wrapFileApi(this); 172 | origAddEventListener.apply(this, [e, changeFnWrapper(fn), b, d]); 173 | } else { 174 | origAddEventListener.apply(this, [e, fn, b, d]); 175 | } 176 | } 177 | })(HTMLInputElement.prototype.addEventListener); 178 | } 179 | if (HTMLInputElement.prototype.attachEvent) { 180 | HTMLInputElement.prototype.attachEvent = (function(origAttachEvent) { 181 | return function(e, fn) { 182 | if (isFileChange(this, e)) { 183 | wrapFileApi(this); 184 | origAttachEvent.apply(this, [e, changeFnWrapper(fn)]); 185 | } else { 186 | origAttachEvent.apply(this, [e, fn]); 187 | } 188 | } 189 | })(HTMLInputElement.prototype.attachEvent); 190 | } 191 | 192 | window.FormData = FormData = function() { 193 | return { 194 | append: function(key, val, name) { 195 | this.data.push({ 196 | key: key, 197 | val: val, 198 | name: name 199 | }); 200 | }, 201 | data: [], 202 | __isShim: true 203 | }; 204 | }; 205 | 206 | (function () { 207 | //load FileAPI 208 | if (!window.FileAPI) { 209 | window.FileAPI = {}; 210 | } 211 | if (!FileAPI.upload) { 212 | var jsUrl, basePath, script = document.createElement('script'), allScripts = document.getElementsByTagName('script'), i, index, src; 213 | if (window.FileAPI.jsUrl) { 214 | jsUrl = window.FileAPI.jsUrl; 215 | } else if (window.FileAPI.jsPath) { 216 | basePath = window.FileAPI.jsPath; 217 | } else { 218 | for (i = 0; i < allScripts.length; i++) { 219 | src = allScripts[i].src; 220 | index = src.indexOf('angular-file-upload-shim.js') 221 | if (index == -1) { 222 | index = src.indexOf('angular-file-upload-shim.min.js'); 223 | } 224 | if (index > -1) { 225 | basePath = src.substring(0, index); 226 | break; 227 | } 228 | } 229 | } 230 | 231 | if (FileAPI.staticPath == null) FileAPI.staticPath = basePath; 232 | script.setAttribute('src', jsUrl || basePath + "FileAPI.min.js"); 233 | document.getElementsByTagName('head')[0].appendChild(script); 234 | } 235 | })(); 236 | } 237 | 238 | 239 | if (!window.FileReader) { 240 | window.FileReader = function() { 241 | var _this = this, loadStarted = false; 242 | this.listeners = {}; 243 | this.addEventListener = function(type, fn) { 244 | _this.listeners[type] = _this.listeners[type] || []; 245 | _this.listeners[type].push(fn); 246 | }; 247 | this.removeEventListener = function(type, fn) { 248 | _this.listeners[type] && _this.listeners[type].splice(_this.listeners[type].indexOf(fn), 1); 249 | }; 250 | this.dispatchEvent = function(evt) { 251 | var list = _this.listeners[evt.type]; 252 | if (list) { 253 | for (var i = 0; i < list.length; i++) { 254 | list[i].call(_this, evt); 255 | } 256 | } 257 | }; 258 | this.onabort = this.onerror = this.onload = this.onloadstart = this.onloadend = this.onprogress = null; 259 | 260 | function constructEvent(type, evt) { 261 | var e = {type: type, target: _this, loaded: evt.loaded, total: evt.total, error: evt.error}; 262 | if (evt.result != null) e.target.result = evt.result; 263 | return e; 264 | }; 265 | var listener = function(evt) { 266 | if (!loadStarted) { 267 | loadStarted = true; 268 | _this.onloadstart && this.onloadstart(constructEvent('loadstart', evt)); 269 | } 270 | if (evt.type === 'load') { 271 | _this.onloadend && _this.onloadend(constructEvent('loadend', evt)); 272 | var e = constructEvent('load', evt); 273 | _this.onload && _this.onload(e); 274 | _this.dispatchEvent(e); 275 | } else if (evt.type === 'progress') { 276 | var e = constructEvent('progress', evt); 277 | _this.onprogress && _this.onprogress(e); 278 | _this.dispatchEvent(e); 279 | } else { 280 | var e = constructEvent('error', evt); 281 | _this.onerror && _this.onerror(e); 282 | _this.dispatchEvent(e); 283 | } 284 | }; 285 | this.readAsArrayBuffer = function(file) { 286 | FileAPI.readAsBinaryString(file, listener); 287 | } 288 | this.readAsBinaryString = function(file) { 289 | FileAPI.readAsBinaryString(file, listener); 290 | } 291 | this.readAsDataURL = function(file) { 292 | FileAPI.readAsDataURL(file, listener); 293 | } 294 | this.readAsText = function(file) { 295 | FileAPI.readAsText(file, listener); 296 | } 297 | } 298 | } 299 | 300 | })(); 301 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Scripts/angular-file-upload.js: -------------------------------------------------------------------------------- 1 | /**! 2 | * AngularJS file upload/drop directive with http post and progress 3 | * @author Danial 4 | * @version 1.2.8 5 | */ 6 | (function() { 7 | 8 | var angularFileUpload = angular.module('angularFileUpload', []); 9 | 10 | angularFileUpload.service('$upload', ['$http', '$rootScope', '$timeout', function($http, $rootScope, $timeout) { 11 | function sendHttp(config) { 12 | config.method = config.method || 'POST'; 13 | config.headers = config.headers || {}; 14 | config.transformRequest = config.transformRequest || function(data) { 15 | if (window.ArrayBuffer && data instanceof ArrayBuffer) { 16 | return data; 17 | } 18 | return $http.defaults.transformRequest[0](data); 19 | }; 20 | 21 | if (window.XMLHttpRequest.__isShim) { 22 | config.headers['__setXHR_'] = function() { 23 | return function(xhr) { 24 | config.__XHR = xhr; 25 | xhr.upload.addEventListener('progress', function(e) { 26 | if (config.progress) { 27 | $timeout(function() { 28 | if(config.progress) config.progress(e); 29 | }); 30 | } 31 | }, false); 32 | //fix for firefox not firing upload progress end, also IE8-9 33 | xhr.upload.addEventListener('load', function(e) { 34 | if (e.lengthComputable) { 35 | $timeout(function() { 36 | if(config.progress) config.progress(e); 37 | }); 38 | } 39 | }, false); 40 | } 41 | }; 42 | } 43 | 44 | var promise = $http(config); 45 | 46 | promise.progress = function(fn) { 47 | config.progress = fn; 48 | return promise; 49 | }; 50 | promise.abort = function() { 51 | if (config.__XHR) { 52 | $timeout(function() { 53 | config.__XHR.abort(); 54 | }); 55 | } 56 | return promise; 57 | }; 58 | promise.then = (function(promise, origThen) { 59 | return function(s, e, p) { 60 | config.progress = p || config.progress; 61 | var result = origThen.apply(promise, [s, e, p]); 62 | result.abort = promise.abort; 63 | result.progress = promise.progress; 64 | return result; 65 | }; 66 | })(promise, promise.then); 67 | 68 | return promise; 69 | }; 70 | this.upload = function(config) { 71 | config.headers = config.headers || {}; 72 | config.headers['Content-Type'] = undefined; 73 | config.transformRequest = config.transformRequest || $http.defaults.transformRequest; 74 | var formData = new FormData(); 75 | if (config.data) { 76 | for (var key in config.data) { 77 | var val = config.data[key]; 78 | if (!config.formDataAppender) { 79 | if (typeof config.transformRequest == 'function') { 80 | val = config.transformRequest(val); 81 | } else { 82 | for (var i = 0; i < config.transformRequest.length; i++) { 83 | var fn = config.transformRequest[i]; 84 | if (typeof fn == 'function') { 85 | val = fn(val); 86 | } 87 | } 88 | } 89 | formData.append(key, val); 90 | } else { 91 | config.formDataAppender(formData, key, val); 92 | } 93 | } 94 | } 95 | config.transformRequest = angular.identity; 96 | 97 | var fileFormName = config.fileFormDataName || 'file'; 98 | 99 | if (Object.prototype.toString.call(config.file) === '[object Array]') { 100 | var isFileFormNameString = Object.prototype.toString.call(fileFormName) === '[object String]'; 101 | for (var i = 0; i < config.file.length; i++) { 102 | formData.append(isFileFormNameString ? fileFormName + i : fileFormName[i], config.file[i], config.file[i].name); 103 | } 104 | } else { 105 | formData.append(fileFormName, config.file, config.file.name); 106 | } 107 | 108 | config.data = formData; 109 | 110 | return sendHttp(config); 111 | }; 112 | this.http = function(config) { 113 | return sendHttp(config); 114 | } 115 | }]); 116 | 117 | angularFileUpload.directive('ngFileSelect', [ '$parse', '$http', '$timeout', function($parse, $http, $timeout) { 118 | return function(scope, elem, attr) { 119 | var fn = $parse(attr['ngFileSelect']); 120 | elem.bind('change', function(evt) { 121 | var files = [], fileList, i; 122 | fileList = evt.target.files; 123 | if (fileList != null) { 124 | for (i = 0; i < fileList.length; i++) { 125 | files.push(fileList.item(i)); 126 | } 127 | } 128 | $timeout(function() { 129 | fn(scope, { 130 | $files : files, 131 | $event : evt 132 | }); 133 | }); 134 | }); 135 | elem.bind('click', function(){ 136 | this.value = null; 137 | }); 138 | }; 139 | } ]); 140 | 141 | angularFileUpload.directive('ngFileDropAvailable', [ '$parse', '$http', '$timeout', function($parse, $http, $timeout) { 142 | return function(scope, elem, attr) { 143 | if ('draggable' in document.createElement('span')) { 144 | var fn = $parse(attr['ngFileDropAvailable']); 145 | $timeout(function() { 146 | fn(scope); 147 | }); 148 | } 149 | }; 150 | } ]); 151 | 152 | angularFileUpload.directive('ngFileDrop', [ '$parse', '$http', '$timeout', function($parse, $http, $timeout) { 153 | return function(scope, elem, attr) { 154 | if ('draggable' in document.createElement('span')) { 155 | var cancel = null; 156 | var fn = $parse(attr['ngFileDrop']); 157 | elem[0].addEventListener("dragover", function(evt) { 158 | $timeout.cancel(cancel); 159 | evt.stopPropagation(); 160 | evt.preventDefault(); 161 | elem.addClass(attr['ngFileDragOverClass'] || "dragover"); 162 | }, false); 163 | elem[0].addEventListener("dragleave", function(evt) { 164 | cancel = $timeout(function() { 165 | elem.removeClass(attr['ngFileDragOverClass'] || "dragover"); 166 | }); 167 | }, false); 168 | elem[0].addEventListener("drop", function(evt) { 169 | evt.stopPropagation(); 170 | evt.preventDefault(); 171 | elem.removeClass(attr['ngFileDragOverClass'] || "dragover"); 172 | var files = [], fileList = evt.dataTransfer.files, i; 173 | if (fileList != null) { 174 | for (i = 0; i < fileList.length; i++) { 175 | files.push(fileList.item(i)); 176 | } 177 | } 178 | $timeout(function() { 179 | fn(scope, { 180 | $files : files, 181 | $event : evt 182 | }); 183 | }); 184 | }, false); 185 | } 186 | }; 187 | } ]); 188 | 189 | })(); 190 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Scripts/angular-route.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license AngularJS v1.2.14 3 | * (c) 2010-2014 Google, Inc. http://angularjs.org 4 | * License: MIT 5 | */ 6 | (function(window, angular, undefined) {'use strict'; 7 | 8 | /** 9 | * @ngdoc module 10 | * @name ngRoute 11 | * @description 12 | * 13 | * # ngRoute 14 | * 15 | * The `ngRoute` module provides routing and deeplinking services and directives for angular apps. 16 | * 17 | * ## Example 18 | * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. 19 | * 20 | * 21 | *
22 | */ 23 | /* global -ngRouteModule */ 24 | var ngRouteModule = angular.module('ngRoute', ['ng']). 25 | provider('$route', $RouteProvider); 26 | 27 | /** 28 | * @ngdoc provider 29 | * @name $routeProvider 30 | * @function 31 | * 32 | * @description 33 | * 34 | * Used for configuring routes. 35 | * 36 | * ## Example 37 | * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. 38 | * 39 | * ## Dependencies 40 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 41 | */ 42 | function $RouteProvider(){ 43 | function inherit(parent, extra) { 44 | return angular.extend(new (angular.extend(function() {}, {prototype:parent}))(), extra); 45 | } 46 | 47 | var routes = {}; 48 | 49 | /** 50 | * @ngdoc method 51 | * @name $routeProvider#when 52 | * 53 | * @param {string} path Route path (matched against `$location.path`). If `$location.path` 54 | * contains redundant trailing slash or is missing one, the route will still match and the 55 | * `$location.path` will be updated to add or drop the trailing slash to exactly match the 56 | * route definition. 57 | * 58 | * * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up 59 | * to the next slash are matched and stored in `$routeParams` under the given `name` 60 | * when the route matches. 61 | * * `path` can contain named groups starting with a colon and ending with a star: 62 | * e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name` 63 | * when the route matches. 64 | * * `path` can contain optional named groups with a question mark: e.g.`:name?`. 65 | * 66 | * For example, routes like `/color/:color/largecode/:largecode*\/edit` will match 67 | * `/color/brown/largecode/code/with/slashes/edit` and extract: 68 | * 69 | * * `color: brown` 70 | * * `largecode: code/with/slashes`. 71 | * 72 | * 73 | * @param {Object} route Mapping information to be assigned to `$route.current` on route 74 | * match. 75 | * 76 | * Object properties: 77 | * 78 | * - `controller` – `{(string|function()=}` – Controller fn that should be associated with 79 | * newly created scope or the name of a {@link angular.Module#controller registered 80 | * controller} if passed as a string. 81 | * - `controllerAs` – `{string=}` – A controller alias name. If present the controller will be 82 | * published to scope under the `controllerAs` name. 83 | * - `template` – `{string=|function()=}` – html template as a string or a function that 84 | * returns an html template as a string which should be used by {@link 85 | * ngRoute.directive:ngView ngView} or {@link ng.directive:ngInclude ngInclude} directives. 86 | * This property takes precedence over `templateUrl`. 87 | * 88 | * If `template` is a function, it will be called with the following parameters: 89 | * 90 | * - `{Array.<Object>}` - route parameters extracted from the current 91 | * `$location.path()` by applying the current route 92 | * 93 | * - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html 94 | * template that should be used by {@link ngRoute.directive:ngView ngView}. 95 | * 96 | * If `templateUrl` is a function, it will be called with the following parameters: 97 | * 98 | * - `{Array.<Object>}` - route parameters extracted from the current 99 | * `$location.path()` by applying the current route 100 | * 101 | * - `resolve` - `{Object.=}` - An optional map of dependencies which should 102 | * be injected into the controller. If any of these dependencies are promises, the router 103 | * will wait for them all to be resolved or one to be rejected before the controller is 104 | * instantiated. 105 | * If all the promises are resolved successfully, the values of the resolved promises are 106 | * injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is 107 | * fired. If any of the promises are rejected the 108 | * {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired. The map object 109 | * is: 110 | * 111 | * - `key` – `{string}`: a name of a dependency to be injected into the controller. 112 | * - `factory` - `{string|function}`: If `string` then it is an alias for a service. 113 | * Otherwise if function, then it is {@link auto.$injector#invoke injected} 114 | * and the return value is treated as the dependency. If the result is a promise, it is 115 | * resolved before its value is injected into the controller. Be aware that 116 | * `ngRoute.$routeParams` will still refer to the previous route within these resolve 117 | * functions. Use `$route.current.params` to access the new route parameters, instead. 118 | * 119 | * - `redirectTo` – {(string|function())=} – value to update 120 | * {@link ng.$location $location} path with and trigger route redirection. 121 | * 122 | * If `redirectTo` is a function, it will be called with the following parameters: 123 | * 124 | * - `{Object.}` - route parameters extracted from the current 125 | * `$location.path()` by applying the current route templateUrl. 126 | * - `{string}` - current `$location.path()` 127 | * - `{Object}` - current `$location.search()` 128 | * 129 | * The custom `redirectTo` function is expected to return a string which will be used 130 | * to update `$location.path()` and `$location.search()`. 131 | * 132 | * - `[reloadOnSearch=true]` - {boolean=} - reload route when only `$location.search()` 133 | * or `$location.hash()` changes. 134 | * 135 | * If the option is set to `false` and url in the browser changes, then 136 | * `$routeUpdate` event is broadcasted on the root scope. 137 | * 138 | * - `[caseInsensitiveMatch=false]` - {boolean=} - match routes without being case sensitive 139 | * 140 | * If the option is set to `true`, then the particular route can be matched without being 141 | * case sensitive 142 | * 143 | * @returns {Object} self 144 | * 145 | * @description 146 | * Adds a new route definition to the `$route` service. 147 | */ 148 | this.when = function(path, route) { 149 | routes[path] = angular.extend( 150 | {reloadOnSearch: true}, 151 | route, 152 | path && pathRegExp(path, route) 153 | ); 154 | 155 | // create redirection for trailing slashes 156 | if (path) { 157 | var redirectPath = (path[path.length-1] == '/') 158 | ? path.substr(0, path.length-1) 159 | : path +'/'; 160 | 161 | routes[redirectPath] = angular.extend( 162 | {redirectTo: path}, 163 | pathRegExp(redirectPath, route) 164 | ); 165 | } 166 | 167 | return this; 168 | }; 169 | 170 | /** 171 | * @param path {string} path 172 | * @param opts {Object} options 173 | * @return {?Object} 174 | * 175 | * @description 176 | * Normalizes the given path, returning a regular expression 177 | * and the original path. 178 | * 179 | * Inspired by pathRexp in visionmedia/express/lib/utils.js. 180 | */ 181 | function pathRegExp(path, opts) { 182 | var insensitive = opts.caseInsensitiveMatch, 183 | ret = { 184 | originalPath: path, 185 | regexp: path 186 | }, 187 | keys = ret.keys = []; 188 | 189 | path = path 190 | .replace(/([().])/g, '\\$1') 191 | .replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option){ 192 | var optional = option === '?' ? option : null; 193 | var star = option === '*' ? option : null; 194 | keys.push({ name: key, optional: !!optional }); 195 | slash = slash || ''; 196 | return '' 197 | + (optional ? '' : slash) 198 | + '(?:' 199 | + (optional ? slash : '') 200 | + (star && '(.+?)' || '([^/]+)') 201 | + (optional || '') 202 | + ')' 203 | + (optional || ''); 204 | }) 205 | .replace(/([\/$\*])/g, '\\$1'); 206 | 207 | ret.regexp = new RegExp('^' + path + '$', insensitive ? 'i' : ''); 208 | return ret; 209 | } 210 | 211 | /** 212 | * @ngdoc method 213 | * @name $routeProvider#otherwise 214 | * 215 | * @description 216 | * Sets route definition that will be used on route change when no other route definition 217 | * is matched. 218 | * 219 | * @param {Object} params Mapping information to be assigned to `$route.current`. 220 | * @returns {Object} self 221 | */ 222 | this.otherwise = function(params) { 223 | this.when(null, params); 224 | return this; 225 | }; 226 | 227 | 228 | this.$get = ['$rootScope', 229 | '$location', 230 | '$routeParams', 231 | '$q', 232 | '$injector', 233 | '$http', 234 | '$templateCache', 235 | '$sce', 236 | function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) { 237 | 238 | /** 239 | * @ngdoc service 240 | * @name $route 241 | * @requires $location 242 | * @requires $routeParams 243 | * 244 | * @property {Object} current Reference to the current route definition. 245 | * The route definition contains: 246 | * 247 | * - `controller`: The controller constructor as define in route definition. 248 | * - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for 249 | * controller instantiation. The `locals` contain 250 | * the resolved values of the `resolve` map. Additionally the `locals` also contain: 251 | * 252 | * - `$scope` - The current route scope. 253 | * - `$template` - The current route template HTML. 254 | * 255 | * @property {Array.<Object>} routes Array of all configured routes. 256 | * 257 | * @description 258 | * `$route` is used for deep-linking URLs to controllers and views (HTML partials). 259 | * It watches `$location.url()` and tries to map the path to an existing route definition. 260 | * 261 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 262 | * 263 | * You can define routes through {@link ngRoute.$routeProvider $routeProvider}'s API. 264 | * 265 | * The `$route` service is typically used in conjunction with the 266 | * {@link ngRoute.directive:ngView `ngView`} directive and the 267 | * {@link ngRoute.$routeParams `$routeParams`} service. 268 | * 269 | * @example 270 | This example shows how changing the URL hash causes the `$route` to match a route against the 271 | URL, and the `ngView` pulls in the partial. 272 | 273 | Note that this example is using {@link ng.directive:script inlined templates} 274 | to get it working on jsfiddle as well. 275 | 276 | 277 | 278 |
279 | Choose: 280 | Moby | 281 | Moby: Ch1 | 282 | Gatsby | 283 | Gatsby: Ch4 | 284 | Scarlet Letter
285 | 286 |
287 |
288 | 289 |
$location.path() = {{$location.path()}}
290 |
$route.current.templateUrl = {{$route.current.templateUrl}}
291 |
$route.current.params = {{$route.current.params}}
292 |
$route.current.scope.name = {{$route.current.scope.name}}
293 |
$routeParams = {{$routeParams}}
294 |
295 |
296 | 297 | 298 | controller: {{name}}
299 | Book Id: {{params.bookId}}
300 |
301 | 302 | 303 | controller: {{name}}
304 | Book Id: {{params.bookId}}
305 | Chapter Id: {{params.chapterId}} 306 |
307 | 308 | 309 | angular.module('ngRouteExample', ['ngRoute']) 310 | 311 | .config(function($routeProvider, $locationProvider) { 312 | $routeProvider.when('/Book/:bookId', { 313 | templateUrl: 'book.html', 314 | controller: BookCntl, 315 | resolve: { 316 | // I will cause a 1 second delay 317 | delay: function($q, $timeout) { 318 | var delay = $q.defer(); 319 | $timeout(delay.resolve, 1000); 320 | return delay.promise; 321 | } 322 | } 323 | }); 324 | $routeProvider.when('/Book/:bookId/ch/:chapterId', { 325 | templateUrl: 'chapter.html', 326 | controller: ChapterCntl 327 | }); 328 | 329 | // configure html5 to get links working on jsfiddle 330 | $locationProvider.html5Mode(true); 331 | }); 332 | 333 | function MainCntl($scope, $route, $routeParams, $location) { 334 | $scope.$route = $route; 335 | $scope.$location = $location; 336 | $scope.$routeParams = $routeParams; 337 | } 338 | 339 | function BookCntl($scope, $routeParams) { 340 | $scope.name = "BookCntl"; 341 | $scope.params = $routeParams; 342 | } 343 | 344 | function ChapterCntl($scope, $routeParams) { 345 | $scope.name = "ChapterCntl"; 346 | $scope.params = $routeParams; 347 | } 348 | 349 | 350 | 351 | it('should load and compile correct template', function() { 352 | element(by.linkText('Moby: Ch1')).click(); 353 | var content = element(by.css('[ng-view]')).getText(); 354 | expect(content).toMatch(/controller\: ChapterCntl/); 355 | expect(content).toMatch(/Book Id\: Moby/); 356 | expect(content).toMatch(/Chapter Id\: 1/); 357 | 358 | element(by.partialLinkText('Scarlet')).click(); 359 | 360 | content = element(by.css('[ng-view]')).getText(); 361 | expect(content).toMatch(/controller\: BookCntl/); 362 | expect(content).toMatch(/Book Id\: Scarlet/); 363 | }); 364 | 365 |
366 | */ 367 | 368 | /** 369 | * @ngdoc event 370 | * @name $route#$routeChangeStart 371 | * @eventType broadcast on root scope 372 | * @description 373 | * Broadcasted before a route change. At this point the route services starts 374 | * resolving all of the dependencies needed for the route change to occur. 375 | * Typically this involves fetching the view template as well as any dependencies 376 | * defined in `resolve` route property. Once all of the dependencies are resolved 377 | * `$routeChangeSuccess` is fired. 378 | * 379 | * @param {Object} angularEvent Synthetic event object. 380 | * @param {Route} next Future route information. 381 | * @param {Route} current Current route information. 382 | */ 383 | 384 | /** 385 | * @ngdoc event 386 | * @name $route#$routeChangeSuccess 387 | * @eventType broadcast on root scope 388 | * @description 389 | * Broadcasted after a route dependencies are resolved. 390 | * {@link ngRoute.directive:ngView ngView} listens for the directive 391 | * to instantiate the controller and render the view. 392 | * 393 | * @param {Object} angularEvent Synthetic event object. 394 | * @param {Route} current Current route information. 395 | * @param {Route|Undefined} previous Previous route information, or undefined if current is 396 | * first route entered. 397 | */ 398 | 399 | /** 400 | * @ngdoc event 401 | * @name $route#$routeChangeError 402 | * @eventType broadcast on root scope 403 | * @description 404 | * Broadcasted if any of the resolve promises are rejected. 405 | * 406 | * @param {Object} angularEvent Synthetic event object 407 | * @param {Route} current Current route information. 408 | * @param {Route} previous Previous route information. 409 | * @param {Route} rejection Rejection of the promise. Usually the error of the failed promise. 410 | */ 411 | 412 | /** 413 | * @ngdoc event 414 | * @name $route#$routeUpdate 415 | * @eventType broadcast on root scope 416 | * @description 417 | * 418 | * The `reloadOnSearch` property has been set to false, and we are reusing the same 419 | * instance of the Controller. 420 | */ 421 | 422 | var forceReload = false, 423 | $route = { 424 | routes: routes, 425 | 426 | /** 427 | * @ngdoc method 428 | * @name $route#reload 429 | * 430 | * @description 431 | * Causes `$route` service to reload the current route even if 432 | * {@link ng.$location $location} hasn't changed. 433 | * 434 | * As a result of that, {@link ngRoute.directive:ngView ngView} 435 | * creates new scope, reinstantiates the controller. 436 | */ 437 | reload: function() { 438 | forceReload = true; 439 | $rootScope.$evalAsync(updateRoute); 440 | } 441 | }; 442 | 443 | $rootScope.$on('$locationChangeSuccess', updateRoute); 444 | 445 | return $route; 446 | 447 | ///////////////////////////////////////////////////// 448 | 449 | /** 450 | * @param on {string} current url 451 | * @param route {Object} route regexp to match the url against 452 | * @return {?Object} 453 | * 454 | * @description 455 | * Check if the route matches the current url. 456 | * 457 | * Inspired by match in 458 | * visionmedia/express/lib/router/router.js. 459 | */ 460 | function switchRouteMatcher(on, route) { 461 | var keys = route.keys, 462 | params = {}; 463 | 464 | if (!route.regexp) return null; 465 | 466 | var m = route.regexp.exec(on); 467 | if (!m) return null; 468 | 469 | for (var i = 1, len = m.length; i < len; ++i) { 470 | var key = keys[i - 1]; 471 | 472 | var val = 'string' == typeof m[i] 473 | ? decodeURIComponent(m[i]) 474 | : m[i]; 475 | 476 | if (key && val) { 477 | params[key.name] = val; 478 | } 479 | } 480 | return params; 481 | } 482 | 483 | function updateRoute() { 484 | var next = parseRoute(), 485 | last = $route.current; 486 | 487 | if (next && last && next.$$route === last.$$route 488 | && angular.equals(next.pathParams, last.pathParams) 489 | && !next.reloadOnSearch && !forceReload) { 490 | last.params = next.params; 491 | angular.copy(last.params, $routeParams); 492 | $rootScope.$broadcast('$routeUpdate', last); 493 | } else if (next || last) { 494 | forceReload = false; 495 | $rootScope.$broadcast('$routeChangeStart', next, last); 496 | $route.current = next; 497 | if (next) { 498 | if (next.redirectTo) { 499 | if (angular.isString(next.redirectTo)) { 500 | $location.path(interpolate(next.redirectTo, next.params)).search(next.params) 501 | .replace(); 502 | } else { 503 | $location.url(next.redirectTo(next.pathParams, $location.path(), $location.search())) 504 | .replace(); 505 | } 506 | } 507 | } 508 | 509 | $q.when(next). 510 | then(function() { 511 | if (next) { 512 | var locals = angular.extend({}, next.resolve), 513 | template, templateUrl; 514 | 515 | angular.forEach(locals, function(value, key) { 516 | locals[key] = angular.isString(value) ? 517 | $injector.get(value) : $injector.invoke(value); 518 | }); 519 | 520 | if (angular.isDefined(template = next.template)) { 521 | if (angular.isFunction(template)) { 522 | template = template(next.params); 523 | } 524 | } else if (angular.isDefined(templateUrl = next.templateUrl)) { 525 | if (angular.isFunction(templateUrl)) { 526 | templateUrl = templateUrl(next.params); 527 | } 528 | templateUrl = $sce.getTrustedResourceUrl(templateUrl); 529 | if (angular.isDefined(templateUrl)) { 530 | next.loadedTemplateUrl = templateUrl; 531 | template = $http.get(templateUrl, {cache: $templateCache}). 532 | then(function(response) { return response.data; }); 533 | } 534 | } 535 | if (angular.isDefined(template)) { 536 | locals['$template'] = template; 537 | } 538 | return $q.all(locals); 539 | } 540 | }). 541 | // after route change 542 | then(function(locals) { 543 | if (next == $route.current) { 544 | if (next) { 545 | next.locals = locals; 546 | angular.copy(next.params, $routeParams); 547 | } 548 | $rootScope.$broadcast('$routeChangeSuccess', next, last); 549 | } 550 | }, function(error) { 551 | if (next == $route.current) { 552 | $rootScope.$broadcast('$routeChangeError', next, last, error); 553 | } 554 | }); 555 | } 556 | } 557 | 558 | 559 | /** 560 | * @returns {Object} the current active route, by matching it against the URL 561 | */ 562 | function parseRoute() { 563 | // Match a route 564 | var params, match; 565 | angular.forEach(routes, function(route, path) { 566 | if (!match && (params = switchRouteMatcher($location.path(), route))) { 567 | match = inherit(route, { 568 | params: angular.extend({}, $location.search(), params), 569 | pathParams: params}); 570 | match.$$route = route; 571 | } 572 | }); 573 | // No route matched; fallback to "otherwise" route 574 | return match || routes[null] && inherit(routes[null], {params: {}, pathParams:{}}); 575 | } 576 | 577 | /** 578 | * @returns {string} interpolation of the redirect path with the parameters 579 | */ 580 | function interpolate(string, params) { 581 | var result = []; 582 | angular.forEach((string||'').split(':'), function(segment, i) { 583 | if (i === 0) { 584 | result.push(segment); 585 | } else { 586 | var segmentMatch = segment.match(/(\w+)(.*)/); 587 | var key = segmentMatch[1]; 588 | result.push(params[key]); 589 | result.push(segmentMatch[2] || ''); 590 | delete params[key]; 591 | } 592 | }); 593 | return result.join(''); 594 | } 595 | }]; 596 | } 597 | 598 | ngRouteModule.provider('$routeParams', $RouteParamsProvider); 599 | 600 | 601 | /** 602 | * @ngdoc service 603 | * @name $routeParams 604 | * @requires $route 605 | * 606 | * @description 607 | * The `$routeParams` service allows you to retrieve the current set of route parameters. 608 | * 609 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 610 | * 611 | * The route parameters are a combination of {@link ng.$location `$location`}'s 612 | * {@link ng.$location#search `search()`} and {@link ng.$location#path `path()`}. 613 | * The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched. 614 | * 615 | * In case of parameter name collision, `path` params take precedence over `search` params. 616 | * 617 | * The service guarantees that the identity of the `$routeParams` object will remain unchanged 618 | * (but its properties will likely change) even when a route change occurs. 619 | * 620 | * Note that the `$routeParams` are only updated *after* a route change completes successfully. 621 | * This means that you cannot rely on `$routeParams` being correct in route resolve functions. 622 | * Instead you can use `$route.current.params` to access the new route's parameters. 623 | * 624 | * @example 625 | * ```js 626 | * // Given: 627 | * // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby 628 | * // Route: /Chapter/:chapterId/Section/:sectionId 629 | * // 630 | * // Then 631 | * $routeParams ==> {chapterId:1, sectionId:2, search:'moby'} 632 | * ``` 633 | */ 634 | function $RouteParamsProvider() { 635 | this.$get = function() { return {}; }; 636 | } 637 | 638 | ngRouteModule.directive('ngView', ngViewFactory); 639 | ngRouteModule.directive('ngView', ngViewFillContentFactory); 640 | 641 | 642 | /** 643 | * @ngdoc directive 644 | * @name ngView 645 | * @restrict ECA 646 | * 647 | * @description 648 | * # Overview 649 | * `ngView` is a directive that complements the {@link ngRoute.$route $route} service by 650 | * including the rendered template of the current route into the main layout (`index.html`) file. 651 | * Every time the current route changes, the included view changes with it according to the 652 | * configuration of the `$route` service. 653 | * 654 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 655 | * 656 | * @animations 657 | * enter - animation is used to bring new content into the browser. 658 | * leave - animation is used to animate existing content away. 659 | * 660 | * The enter and leave animation occur concurrently. 661 | * 662 | * @scope 663 | * @priority 400 664 | * @param {string=} onload Expression to evaluate whenever the view updates. 665 | * 666 | * @param {string=} autoscroll Whether `ngView` should call {@link ng.$anchorScroll 667 | * $anchorScroll} to scroll the viewport after the view is updated. 668 | * 669 | * - If the attribute is not set, disable scrolling. 670 | * - If the attribute is set without value, enable scrolling. 671 | * - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated 672 | * as an expression yields a truthy value. 673 | * @example 674 | 677 | 678 |
679 | Choose: 680 | Moby | 681 | Moby: Ch1 | 682 | Gatsby | 683 | Gatsby: Ch4 | 684 | Scarlet Letter
685 | 686 |
687 |
688 |
689 |
690 | 691 |
$location.path() = {{main.$location.path()}}
692 |
$route.current.templateUrl = {{main.$route.current.templateUrl}}
693 |
$route.current.params = {{main.$route.current.params}}
694 |
$route.current.scope.name = {{main.$route.current.scope.name}}
695 |
$routeParams = {{main.$routeParams}}
696 |
697 |
698 | 699 | 700 |
701 | controller: {{book.name}}
702 | Book Id: {{book.params.bookId}}
703 |
704 |
705 | 706 | 707 |
708 | controller: {{chapter.name}}
709 | Book Id: {{chapter.params.bookId}}
710 | Chapter Id: {{chapter.params.chapterId}} 711 |
712 |
713 | 714 | 715 | .view-animate-container { 716 | position:relative; 717 | height:100px!important; 718 | position:relative; 719 | background:white; 720 | border:1px solid black; 721 | height:40px; 722 | overflow:hidden; 723 | } 724 | 725 | .view-animate { 726 | padding:10px; 727 | } 728 | 729 | .view-animate.ng-enter, .view-animate.ng-leave { 730 | -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s; 731 | transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s; 732 | 733 | display:block; 734 | width:100%; 735 | border-left:1px solid black; 736 | 737 | position:absolute; 738 | top:0; 739 | left:0; 740 | right:0; 741 | bottom:0; 742 | padding:10px; 743 | } 744 | 745 | .view-animate.ng-enter { 746 | left:100%; 747 | } 748 | .view-animate.ng-enter.ng-enter-active { 749 | left:0; 750 | } 751 | .view-animate.ng-leave.ng-leave-active { 752 | left:-100%; 753 | } 754 | 755 | 756 | 757 | angular.module('ngViewExample', ['ngRoute', 'ngAnimate'], 758 | function($routeProvider, $locationProvider) { 759 | $routeProvider.when('/Book/:bookId', { 760 | templateUrl: 'book.html', 761 | controller: BookCntl, 762 | controllerAs: 'book' 763 | }); 764 | $routeProvider.when('/Book/:bookId/ch/:chapterId', { 765 | templateUrl: 'chapter.html', 766 | controller: ChapterCntl, 767 | controllerAs: 'chapter' 768 | }); 769 | 770 | // configure html5 to get links working on jsfiddle 771 | $locationProvider.html5Mode(true); 772 | }); 773 | 774 | function MainCntl($route, $routeParams, $location) { 775 | this.$route = $route; 776 | this.$location = $location; 777 | this.$routeParams = $routeParams; 778 | } 779 | 780 | function BookCntl($routeParams) { 781 | this.name = "BookCntl"; 782 | this.params = $routeParams; 783 | } 784 | 785 | function ChapterCntl($routeParams) { 786 | this.name = "ChapterCntl"; 787 | this.params = $routeParams; 788 | } 789 | 790 | 791 | 792 | it('should load and compile correct template', function() { 793 | element(by.linkText('Moby: Ch1')).click(); 794 | var content = element(by.css('[ng-view]')).getText(); 795 | expect(content).toMatch(/controller\: ChapterCntl/); 796 | expect(content).toMatch(/Book Id\: Moby/); 797 | expect(content).toMatch(/Chapter Id\: 1/); 798 | 799 | element(by.partialLinkText('Scarlet')).click(); 800 | 801 | content = element(by.css('[ng-view]')).getText(); 802 | expect(content).toMatch(/controller\: BookCntl/); 803 | expect(content).toMatch(/Book Id\: Scarlet/); 804 | }); 805 | 806 |
807 | */ 808 | 809 | 810 | /** 811 | * @ngdoc event 812 | * @name ngView#$viewContentLoaded 813 | * @eventType emit on the current ngView scope 814 | * @description 815 | * Emitted every time the ngView content is reloaded. 816 | */ 817 | ngViewFactory.$inject = ['$route', '$anchorScroll', '$animate']; 818 | function ngViewFactory( $route, $anchorScroll, $animate) { 819 | return { 820 | restrict: 'ECA', 821 | terminal: true, 822 | priority: 400, 823 | transclude: 'element', 824 | link: function(scope, $element, attr, ctrl, $transclude) { 825 | var currentScope, 826 | currentElement, 827 | previousElement, 828 | autoScrollExp = attr.autoscroll, 829 | onloadExp = attr.onload || ''; 830 | 831 | scope.$on('$routeChangeSuccess', update); 832 | update(); 833 | 834 | function cleanupLastView() { 835 | if(previousElement) { 836 | previousElement.remove(); 837 | previousElement = null; 838 | } 839 | if(currentScope) { 840 | currentScope.$destroy(); 841 | currentScope = null; 842 | } 843 | if(currentElement) { 844 | $animate.leave(currentElement, function() { 845 | previousElement = null; 846 | }); 847 | previousElement = currentElement; 848 | currentElement = null; 849 | } 850 | } 851 | 852 | function update() { 853 | var locals = $route.current && $route.current.locals, 854 | template = locals && locals.$template; 855 | 856 | if (angular.isDefined(template)) { 857 | var newScope = scope.$new(); 858 | var current = $route.current; 859 | 860 | // Note: This will also link all children of ng-view that were contained in the original 861 | // html. If that content contains controllers, ... they could pollute/change the scope. 862 | // However, using ng-view on an element with additional content does not make sense... 863 | // Note: We can't remove them in the cloneAttchFn of $transclude as that 864 | // function is called before linking the content, which would apply child 865 | // directives to non existing elements. 866 | var clone = $transclude(newScope, function(clone) { 867 | $animate.enter(clone, null, currentElement || $element, function onNgViewEnter () { 868 | if (angular.isDefined(autoScrollExp) 869 | && (!autoScrollExp || scope.$eval(autoScrollExp))) { 870 | $anchorScroll(); 871 | } 872 | }); 873 | cleanupLastView(); 874 | }); 875 | 876 | currentElement = clone; 877 | currentScope = current.scope = newScope; 878 | currentScope.$emit('$viewContentLoaded'); 879 | currentScope.$eval(onloadExp); 880 | } else { 881 | cleanupLastView(); 882 | } 883 | } 884 | } 885 | }; 886 | } 887 | 888 | // This directive is called during the $transclude call of the first `ngView` directive. 889 | // It will replace and compile the content of the element with the loaded template. 890 | // We need this directive so that the element content is already filled when 891 | // the link function of another directive on the same element as ngView 892 | // is called. 893 | ngViewFillContentFactory.$inject = ['$compile', '$controller', '$route']; 894 | function ngViewFillContentFactory($compile, $controller, $route) { 895 | return { 896 | restrict: 'ECA', 897 | priority: -400, 898 | link: function(scope, $element) { 899 | var current = $route.current, 900 | locals = current.locals; 901 | 902 | $element.html(locals.$template); 903 | 904 | var link = $compile($element.contents()); 905 | 906 | if (current.controller) { 907 | locals.$scope = scope; 908 | var controller = $controller(current.controller, locals); 909 | if (current.controllerAs) { 910 | scope[current.controllerAs] = controller; 911 | } 912 | $element.data('$ngControllerController', controller); 913 | $element.children().data('$ngControllerController', controller); 914 | } 915 | 916 | link(scope); 917 | } 918 | }; 919 | } 920 | 921 | 922 | })(window, window.angular); 923 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 6 | 7 | 8 | 9 | 10 | Index 11 | 12 | 13 | 14 |
15 |
16 |

Web API File uploading using AngularJS client. Read more at chsakell.com.

17 |
18 |
19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Views/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/WebApiFileUpload.API.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {640F50D8-60BB-49BB-B716-15F67DC3A585} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | WebApiFileUpload.API 15 | WebApiFileUpload.API 16 | v4.5.1 17 | true 18 | 19 | 20 | 21 | 22 | ..\ 23 | true 24 | 25 | 26 | true 27 | full 28 | false 29 | bin\ 30 | DEBUG;TRACE 31 | prompt 32 | 4 33 | 34 | 35 | pdbonly 36 | true 37 | bin\ 38 | TRACE 39 | prompt 40 | 4 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | ..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll 65 | 66 | 67 | ..\packages\Microsoft.AspNet.Webpages.3.2.2\lib\net45\System.Web.Webpages.dll 68 | 69 | 70 | ..\packages\Microsoft.AspNet.Webpages.3.2.2\lib\net45\System.Web.Webpages.Deployment.dll 71 | 72 | 73 | ..\packages\Microsoft.AspNet.Webpages.3.2.2\lib\net45\System.Web.Webpages.Razor.dll 74 | 75 | 76 | ..\packages\Microsoft.AspNet.Webpages.3.2.2\lib\net45\System.Web.Helpers.dll 77 | 78 | 79 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 80 | 81 | 82 | ..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll 83 | 84 | 85 | ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll 86 | 87 | 88 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll 89 | 90 | 91 | ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll 92 | 93 | 94 | ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | Global.asax 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | Web.config 129 | 130 | 131 | Web.config 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 10.0 141 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | True 151 | True 152 | 48697 153 | / 154 | http://localhost:48697/ 155 | False 156 | False 157 | 158 | 159 | False 160 | 161 | 162 | 163 | 164 | 165 | 172 | -------------------------------------------------------------------------------- /WebApiFileUpload.API/app/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('angularUploadApp', [ 4 | 'ngRoute', 5 | 'angularFileUpload' 6 | ]) 7 | 8 | .config(function ($routeProvider) { 9 | $routeProvider 10 | .when('/', { 11 | templateUrl: 'app/templates/fileUpload.html', 12 | controller: 'fileUploadCtrl' 13 | }) 14 | .otherwise({ 15 | redirectTo: '/' 16 | }); 17 | }); -------------------------------------------------------------------------------- /WebApiFileUpload.API/app/controllers/fileUploadCtrl.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('angularUploadApp') 4 | .controller('fileUploadCtrl', function ($scope, $http, $timeout, $upload) { 5 | $scope.upload = []; 6 | $scope.UploadedFiles = []; 7 | 8 | $scope.startUploading = function ($files) { 9 | //$files: an array of files selected 10 | for (var i = 0; i < $files.length; i++) { 11 | var $file = $files[i]; 12 | (function (index) { 13 | $scope.upload[index] = $upload.upload({ 14 | url: "./api/fileupload", // webapi url 15 | method: "POST", 16 | file: $file 17 | }).progress(function (evt) { 18 | }).success(function (data, status, headers, config) { 19 | // file is uploaded successfully 20 | $scope.UploadedFiles.push({ FileName: data.FileName, FilePath: data.LocalFilePath, FileLength : data.FileLength }); 21 | }).error(function (data, status, headers, config) { 22 | console.log(data); 23 | }); 24 | })(i); 25 | } 26 | } 27 | 28 | $scope.abortUpload = function (index) { 29 | $scope.upload[index].abort(); 30 | } 31 | }); -------------------------------------------------------------------------------- /WebApiFileUpload.API/app/templates/fileUpload.html: -------------------------------------------------------------------------------- 1 | 
2 |
3 |
4 | 5 |
6 |
7 |
8 |
9 |
10 | {{uploadedFile.FileName}} 11 |
12 |
13 |
14 | 15 | 16 | 17 |
18 |
{{uploadedFile.FilePath}}
19 |
20 |
21 |
22 | 25 |
26 |
27 |
-------------------------------------------------------------------------------- /WebApiFileUpload.API/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WebApiFileUpload.DesktopClient 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textBox1 = new System.Windows.Forms.TextBox(); 32 | this.linkLabel1 = new System.Windows.Forms.LinkLabel(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.label2 = new System.Windows.Forms.Label(); 35 | this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); 36 | this.button1 = new System.Windows.Forms.Button(); 37 | this.SuspendLayout(); 38 | // 39 | // textBox1 40 | // 41 | this.textBox1.BackColor = System.Drawing.SystemColors.ControlLightLight; 42 | this.textBox1.ForeColor = System.Drawing.SystemColors.MenuHighlight; 43 | this.textBox1.Location = new System.Drawing.Point(3, 84); 44 | this.textBox1.Multiline = true; 45 | this.textBox1.Name = "textBox1"; 46 | this.textBox1.ReadOnly = true; 47 | this.textBox1.Size = new System.Drawing.Size(511, 124); 48 | this.textBox1.TabIndex = 0; 49 | this.textBox1.VisibleChanged += new System.EventHandler(this.textBox1_VisibleChanged); 50 | // 51 | // linkLabel1 52 | // 53 | this.linkLabel1.AutoSize = true; 54 | this.linkLabel1.Location = new System.Drawing.Point(3, 220); 55 | this.linkLabel1.Name = "linkLabel1"; 56 | this.linkLabel1.Size = new System.Drawing.Size(76, 13); 57 | this.linkLabel1.TabIndex = 1; 58 | this.linkLabel1.TabStop = true; 59 | this.linkLabel1.Text = "chsakell\'s blog"; 60 | this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); 61 | // 62 | // label1 63 | // 64 | this.label1.AutoSize = true; 65 | this.label1.Location = new System.Drawing.Point(3, 9); 66 | this.label1.Name = "label1"; 67 | this.label1.Size = new System.Drawing.Size(195, 13); 68 | this.label1.TabIndex = 2; 69 | this.label1.Text = "Web API File uploading using HttpClient"; 70 | // 71 | // label2 72 | // 73 | this.label2.AutoSize = true; 74 | this.label2.Location = new System.Drawing.Point(6, 43); 75 | this.label2.Name = "label2"; 76 | this.label2.Size = new System.Drawing.Size(78, 13); 77 | this.label2.TabIndex = 3; 78 | this.label2.Text = "Files to upload:"; 79 | // 80 | // openFileDialog1 81 | // 82 | this.openFileDialog1.FileName = "openFileDialog1"; 83 | this.openFileDialog1.Multiselect = true; 84 | // 85 | // button1 86 | // 87 | this.button1.Location = new System.Drawing.Point(110, 38); 88 | this.button1.Name = "button1"; 89 | this.button1.Size = new System.Drawing.Size(115, 23); 90 | this.button1.TabIndex = 4; 91 | this.button1.Text = "Browse.."; 92 | this.button1.UseVisualStyleBackColor = true; 93 | this.button1.Click += new System.EventHandler(this.button1_Click); 94 | // 95 | // Form1 96 | // 97 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 98 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 99 | this.BackColor = System.Drawing.SystemColors.ControlLightLight; 100 | this.ClientSize = new System.Drawing.Size(520, 245); 101 | this.Controls.Add(this.button1); 102 | this.Controls.Add(this.label2); 103 | this.Controls.Add(this.label1); 104 | this.Controls.Add(this.linkLabel1); 105 | this.Controls.Add(this.textBox1); 106 | this.MaximizeBox = false; 107 | this.MinimizeBox = false; 108 | this.Name = "Form1"; 109 | this.Text = "WebAPI File Uploading"; 110 | this.Load += new System.EventHandler(this.Form1_Load); 111 | this.ResumeLayout(false); 112 | this.PerformLayout(); 113 | 114 | } 115 | 116 | #endregion 117 | 118 | private System.Windows.Forms.TextBox textBox1; 119 | private System.Windows.Forms.LinkLabel linkLabel1; 120 | private System.Windows.Forms.Label label1; 121 | private System.Windows.Forms.Label label2; 122 | private System.Windows.Forms.OpenFileDialog openFileDialog1; 123 | private System.Windows.Forms.Button button1; 124 | } 125 | } 126 | 127 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Diagnostics; 6 | using System.Drawing; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Net.Http; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using System.Windows.Forms; 13 | using WebApiFileUpload.API.Infrastructure; 14 | 15 | namespace WebApiFileUpload.DesktopClient 16 | { 17 | public partial class Form1 : Form 18 | { 19 | const string uploadServiceBaseAddress = "http://localhost:48697/api/fileupload"; 20 | public Form1() 21 | { 22 | InitializeComponent(); 23 | } 24 | 25 | private void textBox1_VisibleChanged(object sender, EventArgs e) 26 | { 27 | if (textBox1.Visible) 28 | { 29 | textBox1.SelectionStart = textBox1.TextLength; 30 | textBox1.ScrollToCaret(); 31 | } 32 | 33 | } 34 | 35 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 36 | { 37 | ProcessStartInfo sInfo = new ProcessStartInfo(e.Link.LinkData.ToString()); 38 | Process.Start(sInfo); 39 | } 40 | 41 | private void Form1_Load(object sender, EventArgs e) 42 | { 43 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 44 | this.linkLabel1.Links.Remove(linkLabel1.Links[0]); 45 | this.linkLabel1.Links.Add(0, linkLabel1.Text.Length, "http://chsakell.com/"); 46 | 47 | // Set the file dialog to filter for graphics files. 48 | this.openFileDialog1.Filter = 49 | "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|" + 50 | "All files (*.*)|*.*"; 51 | 52 | // Allow the user to select multiple images. 53 | this.openFileDialog1.Multiselect = true; 54 | this.openFileDialog1.Title = "Browse files to upload."; 55 | } 56 | 57 | private void button1_Click(object sender, EventArgs e) 58 | { 59 | DialogResult dr = this.openFileDialog1.ShowDialog(); 60 | if (dr == System.Windows.Forms.DialogResult.OK) 61 | { 62 | try 63 | { 64 | HttpClient httpClient = new HttpClient(); 65 | // Read the files 66 | foreach (String file in openFileDialog1.FileNames) 67 | { 68 | 69 | var fileStream = File.Open(file, FileMode.Open); 70 | var fileInfo = new FileInfo(file); 71 | FileUploadResult uploadResult = null; 72 | bool _fileUploaded = false; 73 | 74 | var content = new MultipartFormDataContent(); 75 | content.Add(new StreamContent(fileStream), "\"file\"", string.Format("\"{0}\"", fileInfo.Name) 76 | ); 77 | 78 | Task taskUpload = httpClient.PostAsync(uploadServiceBaseAddress, content).ContinueWith(task => 79 | { 80 | if (task.Status == TaskStatus.RanToCompletion) 81 | { 82 | var response = task.Result; 83 | 84 | if (response.IsSuccessStatusCode) 85 | { 86 | uploadResult = response.Content.ReadAsAsync().Result; 87 | if (uploadResult != null) 88 | _fileUploaded = true; 89 | 90 | // Read other header values if you want.. 91 | foreach (var header in response.Content.Headers) 92 | { 93 | Debug.WriteLine("{0}: {1}", header.Key, string.Join(",", header.Value)); 94 | } 95 | } 96 | else 97 | { 98 | Debug.WriteLine("Status Code: {0} - {1}", response.StatusCode, response.ReasonPhrase); 99 | Debug.WriteLine("Response Body: {0}", response.Content.ReadAsStringAsync().Result); 100 | } 101 | } 102 | 103 | fileStream.Dispose(); 104 | }); 105 | 106 | taskUpload.Wait(); 107 | if (_fileUploaded) 108 | AddMessage(uploadResult.FileName + " with length " + uploadResult.FileLength 109 | + " has been uploaded at " + uploadResult.LocalFilePath); 110 | } 111 | 112 | httpClient.Dispose(); 113 | } 114 | catch (Exception ex) 115 | { 116 | AddMessage(ex.Message); 117 | } 118 | } 119 | } 120 | 121 | private void AddMessage(string message) 122 | { 123 | try 124 | { 125 | textBox1.AppendText(message); 126 | textBox1.AppendText(Environment.NewLine); 127 | textBox1.AppendText(Environment.NewLine); 128 | } 129 | catch 130 | { 131 | } 132 | } 133 | 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Form1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace WebApiFileUpload.DesktopClient 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("WebApiFileUpload.DesktopClient")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WebApiFileUpload.DesktopClient")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3875f5a0-9258-43dd-832f-8c2a4aa1f174")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WebApiFileUpload.DesktopClient.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WebApiFileUpload.DesktopClient.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WebApiFileUpload.DesktopClient.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/WebApiFileUpload.DesktopClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4FFDF69E-BB28-4FA1-A6B5-E498BC5D1AE0} 8 | WinExe 9 | Properties 10 | WebApiFileUpload.DesktopClient 11 | WebApiFileUpload.DesktopClient 12 | v4.5.1 13 | 512 14 | 15 | ..\ 16 | true 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | False 40 | ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll 41 | 42 | 43 | 44 | 45 | 46 | False 47 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Form 61 | 62 | 63 | Form1.cs 64 | 65 | 66 | 67 | 68 | Form1.cs 69 | 70 | 71 | ResXFileCodeGenerator 72 | Resources.Designer.cs 73 | Designer 74 | 75 | 76 | True 77 | Resources.resx 78 | True 79 | 80 | 81 | 82 | SettingsSingleFileGenerator 83 | Settings.Designer.cs 84 | 85 | 86 | True 87 | Settings.settings 88 | True 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | {640f50d8-60bb-49bb-b716-15f67dc3a585} 97 | WebApiFileUpload.API 98 | 99 | 100 | 101 | 102 | 109 | -------------------------------------------------------------------------------- /WebApiFileUpload.DesktopClient/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /WebApiFileUpload.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiFileUpload.API", "WebApiFileUpload.API\WebApiFileUpload.API.csproj", "{640F50D8-60BB-49BB-B716-15F67DC3A585}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiFileUpload.DesktopClient", "WebApiFileUpload.DesktopClient\WebApiFileUpload.DesktopClient.csproj", "{4FFDF69E-BB28-4FA1-A6B5-E498BC5D1AE0}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{3CB00947-2B56-4328-B49B-2A8693980494}" 11 | ProjectSection(SolutionItems) = preProject 12 | .nuget\NuGet.Config = .nuget\NuGet.Config 13 | .nuget\NuGet.exe = .nuget\NuGet.exe 14 | .nuget\NuGet.targets = .nuget\NuGet.targets 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {640F50D8-60BB-49BB-B716-15F67DC3A585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {640F50D8-60BB-49BB-B716-15F67DC3A585}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {640F50D8-60BB-49BB-B716-15F67DC3A585}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {640F50D8-60BB-49BB-B716-15F67DC3A585}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {4FFDF69E-BB28-4FA1-A6B5-E498BC5D1AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {4FFDF69E-BB28-4FA1-A6B5-E498BC5D1AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {4FFDF69E-BB28-4FA1-A6B5-E498BC5D1AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {4FFDF69E-BB28-4FA1-A6B5-E498BC5D1AE0}.Release|Any CPU.Build.0 = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | EndGlobal 36 | -------------------------------------------------------------------------------- /licence: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 chsakell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/repositories.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------