1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-03-31 18:36:15 -04:00
Files
Radarr/src/NzbDrone.Common/Extensions/StreamExtensions.cs
2020-05-20 11:00:20 -04:00

24 lines
598 B
C#

using System.IO;
using System.Threading.Tasks;
namespace NzbDrone.Common.Extensions
{
public static class StreamExtensions
{
public static async Task<byte[]> ToBytes(this Stream input)
{
var buffer = new byte[16 * 1024];
using (var ms = new MemoryStream())
{
int read;
while ((read = await input.ReadAsync(buffer, 0, buffer.Length)) > 0)
{
await ms.WriteAsync(buffer, 0, read);
}
return ms.ToArray();
}
}
}
}