Changed song streaming to use only FileStream instead of FileStream and MemoryStream
This commit is contained in:
@@ -47,17 +47,14 @@ namespace Icarus.Controllers.V1
|
|||||||
|
|
||||||
var song = songStore.GetSong(new Song { Id = id });
|
var song = songStore.GetSong(new Song { Id = id });
|
||||||
|
|
||||||
var mem = new MemoryStream();
|
var stream = new FileStream(song.SongPath, FileMode.Open, FileAccess.Read);
|
||||||
|
stream.Position = 0;
|
||||||
using (var stream = new FileStream(song.SongPath, FileMode.Open, FileAccess.Read))
|
var filename = $"{song.Title}.mp3";
|
||||||
await stream.CopyToAsync(mem);
|
|
||||||
|
|
||||||
mem.Position = 0;
|
|
||||||
|
|
||||||
_logger.LogInformation("Starting to stream song...>");
|
_logger.LogInformation("Starting to stream song...>");
|
||||||
Console.WriteLine("Starting to streamsong...");
|
Console.WriteLine("Starting to streamsong...");
|
||||||
|
|
||||||
return File(mem, "application/octet-stream", Path.GetFileName(song.SongPath));
|
return File(stream, "application/octet-stream", filename);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user