using Microsoft.AspNetCore.Mvc.Formatters; namespace CA_ANC.Formatters; public class Formatters { } public class ByteArrayInputFormatter : InputFormatter { public ByteArrayInputFormatter() { SupportedMediaTypes.Add(Microsoft.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream")); } protected override bool CanReadType(Type type) { return type == typeof(byte[]); } public async override Task ReadRequestBodyAsync(InputFormatterContext context) { var stream = new MemoryStream(); await context.HttpContext.Request.Body.CopyToAsync(stream); return await InputFormatterResult.SuccessAsync(stream.ToArray()); } }