mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 16:46:08 +02:00
feat: add image handling actions and improve IRC message formatting
This commit is contained in:
@@ -19,7 +19,14 @@ public class FilesController : ControllerBase
|
||||
_fileStorage = fileStorage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves an uploaded file. Anonymous by design: the unguessable GUID in the URL is the
|
||||
/// access token (Discord-CDN-style capability URL), so attachment links can be opened
|
||||
/// directly in a browser and shared to IRC clients. E2E-encrypted room blobs are
|
||||
/// ciphertext at rest, so anonymous access reveals nothing for those channels.
|
||||
/// </summary>
|
||||
[HttpGet("{fileId}")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult GetFile(string fileId)
|
||||
{
|
||||
if (!Guid.TryParse(fileId, out _))
|
||||
@@ -48,6 +55,11 @@ public class FilesController : ControllerBase
|
||||
_ => "application/octet-stream"
|
||||
};
|
||||
|
||||
// Images and audio render inline so a browser displays them instead of
|
||||
// downloading; everything else keeps the attachment disposition.
|
||||
if (contentType.StartsWith("image/") || contentType.StartsWith("audio/"))
|
||||
return PhysicalFile(filePath, contentType);
|
||||
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
return PhysicalFile(filePath, contentType, fileName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user