mirror of
https://github.com/fergalmoran/SilkierQuartz.git
synced 2026-01-08 18:04:36 +00:00
30 lines
805 B
C#
30 lines
805 B
C#
using System.IO;
|
|
|
|
namespace Quartzmin.Models
|
|
{
|
|
public class FormFile
|
|
{
|
|
#if ( NETSTANDARD || NETCOREAPP )
|
|
readonly Microsoft.AspNetCore.Http.IFormFile _file;
|
|
public FormFile(Microsoft.AspNetCore.Http.IFormFile file) => _file = file;
|
|
|
|
public Stream GetStream() => _file.OpenReadStream();
|
|
#endif
|
|
#if NETFRAMEWORK
|
|
readonly System.Net.Http.HttpContent _content;
|
|
public FormFile(System.Net.Http.HttpContent content) => _content = content;
|
|
|
|
public Stream GetStream() => _content.ReadAsStreamAsync().GetAwaiter().GetResult();
|
|
#endif
|
|
|
|
public byte[] GetBytes()
|
|
{
|
|
using (var stream = new MemoryStream())
|
|
{
|
|
GetStream().CopyTo(stream);
|
|
return stream.ToArray();
|
|
}
|
|
}
|
|
}
|
|
}
|