Issue
Currently, I am developing a microservice that receives an image, height, and width to resize that image in this resolution. I have done all my backend side, now I am struggling on the front side. What I am trying to do is, send an image, height, and width in the same post request from the postman. After searching, I haven't found a way to do it. I can send it through the request param, but I don't think is the correct way, maybe I am wrong. But, thinking that I have to pass whole my object through the request param it sounds ugly.
What I am trying to do is, in postman Body JSON/raw pass values of the three attributes which are multipart file that take the image, height, and width for the resolution. I can successfully pass the width and height, but I don't know how to pass image from the body raw.
Please, can anyone give any idea?
This is my model.
public class TaskDTO {
private int height;
private int width;
private MultipartFile multipartfile;
Endpoint
@PostMapping("/task")
public void createTask(@RequestBody TaskDTO taskDTO){
//taskService.createTask(file, width, height);
//System.out.println(file);
System.out.println(taskDTO.toString());
//System.out.println(taskDTO.toString());
}
Postman Test
Solution
Here is an example using @ModelAttribute
:
Answered By - Serhii Zhura
Answer Checked By - Willingham (JavaFixing Volunteer)