This commit is contained in:
2026-05-17 20:54:09 -04:00
parent 6da2183583
commit 74c21ee5cc
3000 changed files with 11794 additions and 15301 deletions

View File

@@ -38,6 +38,46 @@ public class FilesController : ControllerBase
return new FileStreamResult(fileStream, GetMimeType(physicalPath));
}
[HttpGet("{id}/small")]
public async Task<IActionResult> GetSmallThumbnail(int id)
{
await using var context = await _context.CreateDbContextAsync();
FilePathListing fileRecord = await context.ArtifactFilePaths.FindAsync(id);
if (fileRecord == null) return NotFound();
var path = !string.IsNullOrEmpty(fileRecord.SmallThumbnailPath) && System.IO.File.Exists(fileRecord.SmallThumbnailPath)
? fileRecord.SmallThumbnailPath
: fileRecord.Path;
if (!System.IO.File.Exists(path)) return NotFound();
var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
var mimeType = path == fileRecord.SmallThumbnailPath ? "image/webp" : GetMimeType(path);
return new FileStreamResult(fileStream, mimeType);
}
[HttpGet("{id}/large")]
public async Task<IActionResult> GetLargeThumbnail(int id)
{
await using var context = await _context.CreateDbContextAsync();
FilePathListing fileRecord = await context.ArtifactFilePaths.FindAsync(id);
if (fileRecord == null) return NotFound();
var path = !string.IsNullOrEmpty(fileRecord.LargeThumbnailPath) && System.IO.File.Exists(fileRecord.LargeThumbnailPath)
? fileRecord.LargeThumbnailPath
: fileRecord.Path;
if (!System.IO.File.Exists(path)) return NotFound();
var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
var mimeType = path == fileRecord.LargeThumbnailPath ? "image/webp" : GetMimeType(path);
return new FileStreamResult(fileStream, mimeType);
}
private static string GetMimeType(string filePath)
{
var extension = Path.GetExtension(filePath).ToLowerInvariant();
@@ -47,6 +87,8 @@ public class FilesController : ControllerBase
".jpeg" => "image/jpeg",
".png" => "image/png",
".gif" => "image/gif",
".txt" => "text/plain",
".pdf" => "application/pdf",
_ => "application/octet-stream", // Default for unknown file types
};
}