Added incoming Cart save functions.

This commit is contained in:
2023-05-18 15:15:17 -04:00
parent ebf3d3069b
commit 6466d17905
2 changed files with 101 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
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<InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context)
{
var stream = new MemoryStream();
await context.HttpContext.Request.Body.CopyToAsync(stream);
return await InputFormatterResult.SuccessAsync(stream.ToArray());
}
}