From 108ed71f645c528ab6d680c568ded7d5f6a36dd0 Mon Sep 17 00:00:00 2001 From: jvyden Date: Wed, 19 Jan 2022 13:06:03 -0500 Subject: [PATCH] fix invalid mimetype when dealing with gameAssets --- .../Controllers/ResourcesController.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ProjectLighthouse/Controllers/ResourcesController.cs b/ProjectLighthouse/Controllers/ResourcesController.cs index 0abf1069..980d985f 100644 --- a/ProjectLighthouse/Controllers/ResourcesController.cs +++ b/ProjectLighthouse/Controllers/ResourcesController.cs @@ -39,8 +39,6 @@ public class ResourcesController : ControllerBase return this.Ok(LbpSerializer.StringElement("resources", resources)); } - [ResponseCache(Duration = 86400)] - [HttpGet("/gameAssets/{hash}")] [HttpGet("r/{hash}")] public IActionResult GetResource(string hash) { @@ -51,6 +49,17 @@ public class ResourcesController : ControllerBase return this.NotFound(); } + [ResponseCache(Duration = 86400)] + [HttpGet("/gameAssets/{hash}")] + public IActionResult GetWebResource(string hash) + { + string path = FileHelper.GetResourcePath(hash); + + if (FileHelper.ResourceExists(hash) && LbpFile.FromHash(hash)?.FileType == LbpFileType.Jpeg) return this.File(IOFile.OpenRead(path), "image/jpeg"); + + return this.NotFound(); + } + // TODO: check if this is a valid hash [HttpPost("upload/{hash}")] public async Task UploadResource(string hash)