Added incoming Cart save functions.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user