1- using Microsoft . AspNetCore . Mvc ;
1+ using Microsoft . AspNetCore . Hosting ;
2+ using Microsoft . AspNetCore . Mvc ;
23using Microsoft . Extensions . Logging ;
34using NetCoreStack . Contracts ;
45using NetCoreStack . Proxy . Test . Contracts ;
56using Newtonsoft . Json ;
67using System ;
78using System . Collections . Generic ;
9+ using System . IO ;
810using System . Threading . Tasks ;
911
1012namespace NetCoreStack . Proxy . Mvc . Hosting . Controllers
1113{
1214 [ Route ( "api/[controller]" ) ]
1315 public class GuidelineController : Controller , IGuidelineApi
1416 {
17+ private readonly IHostingEnvironment _hostingEnvironment ;
1518 private readonly ILoggerFactory _loggerFactory ;
1619 private readonly ILogger _logger ;
1720
18- public GuidelineController ( ILoggerFactory loggerFactory )
21+ public GuidelineController ( IHostingEnvironment hostingEnvironment , ILoggerFactory loggerFactory )
1922 {
23+ _hostingEnvironment = hostingEnvironment ;
2024 _loggerFactory = loggerFactory ;
2125 _logger = _loggerFactory . CreateLogger < GuidelineController > ( ) ;
2226 }
@@ -73,6 +77,24 @@ public async Task TaskActionPost([FromBody]ComplexTypeModel model)
7377 _logger . LogWarning ( JsonConvert . SerializeObject ( model ) ) ;
7478 }
7579
80+ [ HttpPost ( nameof ( TaskSingleFileModel ) ) ]
81+ public async Task TaskSingleFileModel ( SingleFileModel model )
82+ {
83+ await Task . CompletedTask ;
84+
85+ var name = model . File . Name ;
86+ var fileName = model . File . FileName ;
87+ var length = model . File . Length ;
88+
89+ using ( var ms = new MemoryStream ( ) )
90+ {
91+ model . File . CopyTo ( ms ) ;
92+ System . IO . File . WriteAllBytes ( Path . Combine ( _hostingEnvironment . ContentRootPath , fileName ) , ms . ToArray ( ) ) ;
93+ }
94+
95+ _logger . LogWarning ( JsonConvert . SerializeObject ( new { name , fileName , length } ) ) ;
96+ }
97+
7698 [ HttpPut ( "kv" ) ]
7799 public async Task < bool > CreateOrUpdateKey ( string key , Bar body )
78100 {
@@ -87,11 +109,38 @@ public Task<bool> CreateOrUpdateKey(string key)
87109 throw new NotImplementedException ( ) ;
88110 }
89111
112+ [ HttpPut ( nameof ( TaskKeyAndSingleFileModel ) ) ]
113+ public Task TaskKeyAndSingleFileModel ( string key , SingleFileModel model )
114+ {
115+ throw new NotImplementedException ( ) ;
116+ }
117+
118+ [ HttpPut ( nameof ( TaskKeySingleFileAndBarModel ) ) ]
119+ public Task TaskKeySingleFileAndBarModel ( string key , SingleFileModel model , Bar bar )
120+ {
121+ throw new NotImplementedException ( ) ;
122+ }
123+
90124 [ HttpDelete ( nameof ( TaskActionDelete ) ) ]
91125 public async Task TaskActionDelete ( long id )
92126 {
93127 await Task . CompletedTask ;
94128 _logger . LogWarning ( JsonConvert . SerializeObject ( new { id } ) ) ;
95129 }
130+
131+ public Task TaskKeyAndSingleFileAndPropsModel ( string key , SingleFileAndPropsModel model )
132+ {
133+ throw new NotImplementedException ( ) ;
134+ }
135+
136+ public Task TaskEnumerableFileModel ( EnumerableFileModel model )
137+ {
138+ throw new NotImplementedException ( ) ;
139+ }
140+
141+ public Task TaskKeyAndEnumerableFileModel ( string key , EnumerableFileModel model )
142+ {
143+ throw new NotImplementedException ( ) ;
144+ }
96145 }
97146}
0 commit comments