I developed an endpoint in .net core that takes parameters from FromBody as a byte array. This endpoint converts the incoming file into an image and saves it in the folder in the file directory.
I know that the byte array value is a file. But this byte array value comes from outside. I want to get this byte array with the endpoint I wrote. So while testing, I tried all kinds of methods from postman. I put debug but it doesn't go to the breakpoint section.
I want to test this endpoint How can I do?
Endpoint:
[HttpPost("ConvertByteToImageFile")] public async Task<IActionResult> ConvertByteTomageFile([FromBody] byte[] data) { //Resime çevirir. var imageData = GetDataToImage(data); try { //Convert Image. SaveImageToFile(imageData); return Ok($"Image saved successfully at"); } catch (Exception ex) { return StatusCode(500, $"An error occurred: {ex.Message}"); } } [NonAction] public Image GetDataToImage(byte[] byteData) { using (MemoryStream ms = new(byteData)) { Image image = Image.FromStream(ms); return image; } } [NonAction] public void SaveImageToFile(Image image) { try { var imageFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "CameraFiles"); var imageName = Guid.NewGuid().ToString(); // Benzersiz bir isim oluştur // Save image var imagePath = Path.Combine(imageFolderPath, imageName); image.Save(imagePath); } catch (Exception ex) { throw new Exception(ex.Message); } }