Skip to content

Commit 31423ee

Browse files
committed
Add test pics (not demo pics) and PicController
1 parent 08b4f91 commit 31423ee

9 files changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

src/Services/Marketing/Marketing.API/Marketing.API.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
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" />
@@ -53,4 +57,13 @@
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>
631 Bytes
Loading
1.6 KB
Loading
2 KB
Loading
1.26 KB
Loading
1.64 KB
Loading
2.25 KB
Loading

src/Services/Marketing/Marketing.API/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)