File tree Expand file tree Collapse file tree
src/Services/Marketing/Marketing.API Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace Microsoft . eShopOnContainers . Services . Marketing . API . Controllers
2+ {
3+ using Microsoft . AspNetCore . Hosting ;
4+ using Microsoft . AspNetCore . Mvc ;
5+ using System . IO ;
6+
7+
8+ public class PicController : Controller
9+ {
10+ private readonly IHostingEnvironment _env ;
11+ public PicController ( IHostingEnvironment env )
12+ {
13+ _env = env ;
14+ }
15+
16+ [ HttpGet ]
17+ [ Route ( "api/v1/campaigns/{campaignId:int}/pic" ) ]
18+ public IActionResult GetImage ( int campaignId )
19+ {
20+ var webRoot = _env . WebRootPath ;
21+ var path = Path . Combine ( webRoot , campaignId + ".png" ) ;
22+
23+ var buffer = System . IO . File . ReadAllBytes ( path ) ;
24+
25+ return File ( buffer , "image/png" ) ;
26+ }
27+ }
28+ }
Original file line number Diff line number Diff line change 1212
1313 <ItemGroup >
1414 <Folder Include =" Infrastructure\MarketingMigrations\" />
15+ <Content Include =" Pics\**\*;" >
16+ <CopyToPublishDirectory >PreserveNewest</CopyToPublishDirectory >
17+ </Content >
18+ <Folder Include =" Infrastructure\MarketingMigrations\" />
1519 </ItemGroup >
1620 <ItemGroup >
1721 <PackageReference Include =" Autofac.Extensions.DependencyInjection" Version =" 4.1.0" />
5357 <ItemGroup >
5458 <ProjectReference Include =" ..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
5559 </ItemGroup >
60+
61+ <ItemGroup >
62+ <None Update =" Dockerfile" >
63+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
64+ </None >
65+ <None Update =" Pics\*" >
66+ <CopyToOutputDirectory >PreserveNewest</CopyToOutputDirectory >
67+ </None >
68+ </ItemGroup >
5669</Project >
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ public static void Main(string[] args)
1212 . UseKestrel ( )
1313 . UseContentRoot ( Directory . GetCurrentDirectory ( ) )
1414 . UseStartup < Startup > ( )
15+ . UseWebRoot ( "Pics" )
1516 . Build ( ) ;
1617
1718 host . Run ( ) ;
You can’t perform that action at this time.
0 commit comments