mirror of
https://github.com/Ikatono/ComiServ.git
synced 2025-10-28 20:45:35 -05:00
updated controllers and some services to use async/await
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user