Skip to content

Commit b0e2544

Browse files
committed
Test file server
1 parent ab18254 commit b0e2544

File tree

8 files changed

+151
-0
lines changed

8 files changed

+151
-0
lines changed

src/Simplify.Web.Multipart.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29215.179
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Simplify.Web.Multipart", "Simplify.Web.Multipart\Simplify.Web.Multipart.csproj", "{1834BEA8-2331-4A44-86C9-CC764BCA0761}"
77
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestServer", "TestServer\TestServer.csproj", "{4EF29FB7-2D85-4473-840B-02515F5E7CE9}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{1834BEA8-2331-4A44-86C9-CC764BCA0761}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{1834BEA8-2331-4A44-86C9-CC764BCA0761}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{1834BEA8-2331-4A44-86C9-CC764BCA0761}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{4EF29FB7-2D85-4473-840B-02515F5E7CE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{4EF29FB7-2D85-4473-840B-02515F5E7CE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{4EF29FB7-2D85-4473-840B-02515F5E7CE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{4EF29FB7-2D85-4473-840B-02515F5E7CE9}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Simplify.Web;
7+
using Simplify.Web.Attributes;
8+
using Simplify.Web.Multipart.Model;
9+
10+
namespace TestServer.Controllers.Api.v1
11+
{
12+
[Post("/api/v1/testIn")]
13+
public class TestInController : AsyncController<MultipartViewModel>
14+
{
15+
public override async Task<ControllerResponse> Invoke()
16+
{
17+
var file = Model.Files.FirstOrDefault() ?? throw new ArgumentNullException("No files in model");
18+
19+
Trace.WriteLine($"Files count: {Model.Files}");
20+
Trace.WriteLine($"File name: {file.FileName}");
21+
22+
using var stream = new StreamReader(file.Data);
23+
24+
var fileData = await stream.ReadToEndAsync();
25+
26+
Trace.WriteLine($"File content: {fileData}");
27+
28+
return NoContent();
29+
}
30+
}
31+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Simplify.Web;
2+
using Simplify.Web.Attributes;
3+
4+
namespace TestServer.Controllers
5+
{
6+
[Get("status")]
7+
public class StatusController : Controller
8+
{
9+
public override ControllerResponse Invoke()
10+
{
11+
return Content("Service is running!");
12+
}
13+
}
14+
}

src/TestServer/Program.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.AspNetCore;
2+
using Microsoft.AspNetCore.Hosting;
3+
4+
namespace TestServer
5+
{
6+
public class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
CreateWebHostBuilder(args).Build().Run();
11+
}
12+
13+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
14+
WebHost.CreateDefaultBuilder(args)
15+
.UseStartup<Startup>();
16+
}
17+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"iisSettings":
3+
{
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress":
7+
{
8+
"applicationUrl": "http://localhost:5000",
9+
"sslPort": 0
10+
}
11+
},
12+
"profiles":
13+
{
14+
"IIS Express":
15+
{
16+
"commandName": "IISExpress",
17+
"environmentVariables":
18+
{
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
22+
"TesterApp":
23+
{
24+
"commandName": "Project",
25+
"environmentVariables":
26+
{
27+
"ASPNETCORE_ENVIRONMENT": "Development"
28+
},
29+
"launchBrowser": true,
30+
"applicationUrl": "http://localhost:5000"
31+
}
32+
}
33+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Simplify.DI;
2+
using Simplify.Web.Multipart;
3+
4+
namespace TestServer.Setup
5+
{
6+
public static class IocRegistrations
7+
{
8+
public static void Register()
9+
{
10+
DIContainer.Current.RegisterHttpMultipartFormModelBinder();
11+
}
12+
}
13+
}

src/TestServer/Startup.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.Extensions.Hosting;
4+
using Simplify.DI;
5+
using Simplify.Web;
6+
using Simplify.Web.Model;
7+
using Simplify.Web.Multipart.Model.Binding;
8+
using TestServer.Setup;
9+
10+
namespace TestServer
11+
{
12+
public class Startup
13+
{
14+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
15+
{
16+
IocRegistrations.Register();
17+
18+
if (env.IsDevelopment())
19+
app.UseDeveloperExceptionPage();
20+
21+
HttpModelHandler.RegisterModelBinder<HttpMultipartFormModelBinder>();
22+
23+
app.UseSimplifyWeb();
24+
25+
DIContainer.Current.Verify();
26+
}
27+
}
28+
}

src/TestServer/TestServer.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<Version>0.1</Version>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<ProjectReference Include="..\Simplify.Web.Multipart\Simplify.Web.Multipart.csproj" />
8+
</ItemGroup>
9+
</Project>

0 commit comments

Comments
 (0)