mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
19 lines
750 B
C#
19 lines
750 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace RadicadeServer.CDN;
|
|
|
|
[Route("studiocdn")]
|
|
public class StudioAssetsCDN : Controller
|
|
{
|
|
[HttpGet("unityasset/{filename}"), HttpHead("unityasset/{filename}")]
|
|
[HttpGet("roomunityasset/{filename}"), HttpHead("roomunityasset/{filename}")]
|
|
public IActionResult Download(string filename)
|
|
{
|
|
if (string.IsNullOrEmpty(filename) || filename.Length > 80 ||
|
|
filename.Any(c => !char.IsAsciiLetterOrDigit(c) && c != '-')) return BadRequest();
|
|
var path = Path.GetFullPath(Path.Combine(DBConfig.CDNStorage, filename));
|
|
if (!System.IO.File.Exists(path)) return NotFound();
|
|
return PhysicalFile(path, "application/octet-stream", enableRangeProcessing: true);
|
|
}
|
|
}
|