mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-01 09:48:37 +00:00
Move /gameAssets endpoint to controller in website project
This commit is contained in:
parent
326681e380
commit
545b5a0709
2 changed files with 29 additions and 19 deletions
|
@ -59,25 +59,6 @@ public class ResourcesController : ControllerBase
|
||||||
return this.NotFound();
|
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
|
// TODO: check if this is a valid hash
|
||||||
[HttpPost("upload/{hash}/unattributed")]
|
[HttpPost("upload/{hash}/unattributed")]
|
||||||
[HttpPost("upload/{hash}")]
|
[HttpPost("upload/{hash}")]
|
||||||
|
|
29
ProjectLighthouse.Website/Controllers/ResourcesController.cs
Normal file
29
ProjectLighthouse.Website/Controllers/ResourcesController.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue