feat: add audio playback and file download features with corresponding UI updates

This commit is contained in:
HueByte
2026-02-20 20:47:28 +01:00
parent ae06e7ae12
commit a860a8fbc3
15 changed files with 313 additions and 7 deletions
@@ -202,13 +202,16 @@ public class ChannelsController : ControllerBase
if (file.Length > HubConstants.MaxFileSizeBytes)
return BadRequest(new ErrorResponse($"File size exceeds maximum of {HubConstants.MaxFileSizeBytes / (1024 * 1024)} MB."));
// Detect if file is an image by checking magic bytes
// Detect file type: image (magic bytes), audio (extension), or generic file
using var stream = file.OpenReadStream();
var isImage = FileValidationHelper.IsValidImage(stream);
var isAudio = !isImage && FileValidationHelper.IsAudioFile(file.FileName);
var (fileId, filePath) = await _fileStorage.SaveFileAsync(stream, file.FileName);
var messageType = isImage ? MessageType.Image : MessageType.File;
var messageType = isImage ? MessageType.Image
: isAudio ? MessageType.Audio
: MessageType.File;
string content;
if (isImage)
@@ -36,6 +36,13 @@ public class FilesController : ControllerBase
".png" => "image/png",
".gif" => "image/gif",
".webp" => "image/webp",
".mp3" => "audio/mpeg",
".wav" => "audio/wav",
".ogg" => "audio/ogg",
".flac" => "audio/flac",
".aac" => "audio/aac",
".m4a" => "audio/mp4",
".wma" => "audio/x-ms-wma",
".pdf" => "application/pdf",
".txt" => "text/plain",
_ => "application/octet-stream"