mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 16:46:08 +02:00
feat: add audio playback and file download features with corresponding UI updates
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user