updated controllers and some services to use async/await

This commit is contained in:
Cameron
2024-08-29 05:36:01 -05:00
parent 18de6d599b
commit 8302e3ea61
36 changed files with 1981 additions and 1809 deletions

View File

@@ -1,19 +1,25 @@
namespace ComiServ.Extensions
{
public static class StreamExtensions
{
//https://stackoverflow.com/questions/1080442/how-do-i-convert-a-stream-into-a-byte-in-c
//https://archive.ph/QUKys
public static byte[] ReadAllBytes(this Stream instream)
{
if (instream is MemoryStream)
return ((MemoryStream)instream).ToArray();
namespace ComiServ.Extensions;
using (var memoryStream = new MemoryStream())
{
instream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
}
public static class StreamExtensions
{
//https://stackoverflow.com/questions/1080442/how-do-i-convert-a-stream-into-a-byte-in-c
//https://archive.ph/QUKys
public static byte[] ReadAllBytes(this Stream instream)
{
if (instream is MemoryStream)
return ((MemoryStream)instream).ToArray();
using var memoryStream = new MemoryStream();
instream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
public static async Task<byte[]> ReadAllBytesAsync(this Stream instream)
{
if (instream is MemoryStream)
return ((MemoryStream)instream).ToArray();
using var memoryStream = new MemoryStream();
await instream.CopyToAsync(memoryStream);
return memoryStream.ToArray();
}
}