Improved open file endpoint

This commit is contained in:
2025-07-10 19:28:15 +08:00
parent 17330fc104
commit ff0789904d
2 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,3 @@
using Azure.Core;
namespace DysonNetwork.Sphere.Connection;
public class ClientTypeMiddleware(RequestDelegate next)
@ -16,8 +14,8 @@ public class ClientTypeMiddleware(RequestDelegate next)
}
else
{
var userAgent = headers["User-Agent"].ToString();
var accept = headers["Accept"].ToString();
var userAgent = headers.UserAgent.ToString();
var accept = headers.Accept.ToString();
// Priority 2: Check known app User-Agent (backward compatibility)
if (!string.IsNullOrEmpty(userAgent) && userAgent.Contains("Solian"))

View File

@ -19,6 +19,10 @@ public class FileController(
[HttpGet("{id}")]
public async Task<ActionResult> OpenFile(string id, [FromQuery] bool original = false)
{
// Support the file extension for client side data recognize
if (id.Contains("."))
id = id.Split('.').First();
var file = await fs.GetFileAsync(id);
if (file is null) return NotFound();