Browse Source

Add GetAllBytesAsync to AbpFormFileExtensions

This makes it easier to get an array of bytes directly from an `IFormFile`
pull/3116/head
zHaytam 7 years ago
parent
commit
84b7e85d48
  1. 7
      framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Http/AbpFormFileExtensions.cs

7
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<byte[]> GetAllBytesAsync(this IFormFile file)
{
using var stream = file.OpenReadStream();
return await stream.GetAllBytesAsync();
}
}
}

Loading…
Cancel
Save