22 lines
635 B
C#
22 lines
635 B
C#
using System.IO;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace xCommons.Extensions {
|
|
public static partial class XHttpContextExtensions {
|
|
/// <summary>
|
|
/// Convert IFormFile to Bytes Array
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static byte[] ToByteArray (this IFormFile source) {
|
|
//
|
|
byte[] data;
|
|
using (var br = new BinaryReader (source.OpenReadStream ())) {
|
|
data = br.ReadBytes ((int) source.OpenReadStream ().Length);
|
|
}
|
|
|
|
//
|
|
return data;
|
|
}
|
|
}
|
|
} |