Not able to post image to API controller in Postman
I have my controller here -
[Route("upload")] [HttpPost] public async Task<IActionResult> UploadFile(IFormFile image) { FurnitureImage item = new FurnitureImage(); if (ModelState.IsValid) { if (image != null && image.Length > 0) { var fileName = Path.GetFileName(image.FileName); var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\items", fileName); using (var fileSteam = new FileStream(filePath, FileMode.Create)) { await image.CopyToAsync(fileSteam); } item.PictureInfo = new byte[Convert.ToByte(fileName)]; } _furnitureInfoRepository.AddNewFurnitureImage(item); } return View(item); }
Which saves it to memory and then takes the the filename and posts it to the DB.
I would like to test this out in Postman but I keep getting the error that the input is invalid, and it's not even hitting my control. This is what I see in postman -
https://i.redd.it/kvnbvz2cwsc21.png
What am I doing wrong? How can I test this API end point for saving images?
0 comments:
Post a Comment