2024-05-02 15:24:13 -07:00

41 lines
1.0 KiB
C#

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.IO;
using WebAPI;
using WebAPI.Services.Interfaces;
namespace Church.Net.WebAPI.Controllers
{
[Route("[controller]")]
[ApiController]
public class FilesController : ControllerBase
{
private readonly ILoggingService loggingService;
public FilesController(ILoggingService loggingService)
{
this.loggingService = loggingService;
}
[HttpGet("{*filePath}")]
public IActionResult Get(string filePath)
{
try
{
string folderRootPath = "";
#if DEBUG
folderRootPath = "//ArkNAS/docker/ChurchAPI/App_Data/Files";
#else
folderRootPath = "/App_Data/Files";
#endif
return PhysicalFile(System.IO.Path.Combine(folderRootPath, filePath), "image/jpeg");
}
catch (System.Exception ex)
{
loggingService.Error(ex);
return NotFound();
}
}
}
}