Move /gameAssets endpoint to controller in website project

This commit is contained in:
jvyden 2022-05-14 17:45:34 -04:00
commit 545b5a0709
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 29 additions and 19 deletions

View file

@ -59,25 +59,6 @@ public class ResourcesController : ControllerBase
return this.NotFound();
}
[ResponseCache(Duration = 86400)]
[HttpGet("/gameAssets/{hash}")]
public IActionResult GetGameImage(string hash)
{
string path = Path.Combine("png", $"{hash}.png");
if (IOFile.Exists(path))
{
return this.File(IOFile.OpenRead(path), "image/png");
}
LbpFile? file = LbpFile.FromHash(hash);
if (file != null && ImageHelper.LbpFileToPNG(file))
{
return this.File(IOFile.OpenRead(path), "image/png");
}
return this.NotFound();
}
// TODO: check if this is a valid hash
[HttpPost("upload/{hash}/unattributed")]
[HttpPost("upload/{hash}")]

View file

@ -0,0 +1,29 @@
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Files;
using Microsoft.AspNetCore.Mvc;
using IOFile = System.IO.File;
namespace LBPUnion.ProjectLighthouse.Website.Controllers;
[ApiController]
public class ResourcesController : ControllerBase
{
[ResponseCache(Duration = 86400)]
[HttpGet("/gameAssets/{hash}")]
public IActionResult GetGameImage(string hash)
{
string path = Path.Combine("png", $"{hash}.png");
if (IOFile.Exists(path))
{
return this.File(IOFile.OpenRead(path), "image/png");
}
LbpFile? file = LbpFile.FromHash(hash);
if (file != null && ImageHelper.LbpFileToPNG(file))
{
return this.File(IOFile.OpenRead(path), "image/png");
}
return this.NotFound();
}
}