1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| [HttpPost]
[Route("api/post/ChmbreImages")]
public FileContentResult PostImage([FromBody] CHAMBRE chambre)
{
//Depending on if you want the byte array or a memory stream, you can use the below.
var imageDataByteArray = Convert.FromBase64String(chambre.img);
//When creating a stream, you need to reset the position, without it you will see that you always write files with a 0 byte length.
var imageDataStream = new MemoryStream(imageDataByteArray);
imageDataStream.Position = 0;
//Go and do something with the actual data.
//_customerImageService.Upload([...])
//For the purpose of the demo, we return a file so we can ensure it was uploaded correctly.
//But otherwise you can just return a 204 etc.
return File(imageDataByteArray, "image/png");
}
private FileContentResult File(byte[] imageDataByteArray, string p)
{
throw new NotImplementedException();
} |
Partager