From 84b7e85d488ef6b68a0ad8e6a559118da0e98ad7 Mon Sep 17 00:00:00 2001 From: zHaytam Date: Fri, 13 Mar 2020 15:16:27 +0100 Subject: [PATCH] Add GetAllBytesAsync to AbpFormFileExtensions This makes it easier to get an array of bytes directly from an `IFormFile` --- .../Microsoft/AspNetCore/Http/AbpFormFileExtensions.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Http/AbpFormFileExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Http/AbpFormFileExtensions.cs index c808250a3e..dfc4df0339 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Http/AbpFormFileExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Http/AbpFormFileExtensions.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Threading.Tasks; namespace Microsoft.AspNetCore.Http { @@ -11,5 +12,11 @@ namespace Microsoft.AspNetCore.Http return stream.GetAllBytes(); } } + + public static async Task GetAllBytesAsync(this IFormFile file) + { + using var stream = file.OpenReadStream(); + return await stream.GetAllBytesAsync(); + } } }