namespace WhatApi.Endpoints; public class DownloadContentEndpoint : BaseEndpoint { [HttpGet("~/{id:guid}")] public async Task HandleAsync(Guid id, CancellationToken ct = default) { try { var path = Path.Combine(Directory.GetCurrentDirectory(), "files", id.ToString()); await using var file = new FileStream(path, FileMode.Open); if (!file.CanRead) return NotFound(); return File(file, "application/octet-stream", id.ToString()); } catch (Exception e) { if (e is not FileNotFoundException) Console.WriteLine(e); return NotFound(); } } }