Java 如何在postman multipart/form data post请求中随文件发送应用程序/json数据?

Java 如何在postman multipart/form data post请求中随文件发送应用程序/json数据?,java,spring-boot,java-8,postman,Java,Spring Boot,Java 8,Postman,我的要求是这样的。我有一门DTO课,如下所示 public class Employee{ private Long id; private String name; private String designation; private byte[] employeeImage; } 我的API在下面 @PostMapping(value="/createEmployees") public ResponseEntity<List

我的要求是这样的。我有一门DTO课,如下所示

public class Employee{
    private Long id;
    private String name;
    private String designation;
    private byte[] employeeImage;
}
我的API在下面

@PostMapping(value="/createEmployees")
            public ResponseEntity<List<EmployeeDTO>> createEmployees(@RequestParam("id") Long id, 
                    @RequestBody List<EmployeeDTO> employeeList){
}
@PostMapping(value=“/createEmployees”)
public ResponseEntity createEmployees(@RequestParam(“id”)长id,
@请求主体列表(员工列表){
}
我正在尝试使用postman发送请求,但图像无法保存。下面是我的邮递员请求

一切正常,但图像无法保存

非常感谢您的帮助


提前谢谢

如果您发送的是Base 64编码的图像,则还需要对其进行如下解码:

        //This will decode the String which is encoded by using Base64 class
        byte[] imageByte=Base64.decodeBase64(imageByteValue);

        String directory=servletContext.getRealPath("/")+"images/sample.jpg";

        new FileOutputStream(directory).write(imageByte);
        return "success ";

您应该从Employee DTO获取图像,并对其进行解码以保存在相应的目录中。

如果您发送的是Base 64编码的图像,则还应对其进行解码,如下所示:

        //This will decode the String which is encoded by using Base64 class
        byte[] imageByte=Base64.decodeBase64(imageByteValue);

        String directory=servletContext.getRealPath("/")+"images/sample.jpg";

        new FileOutputStream(directory).write(imageByte);
        return "success ";
您应该从Employee DTO获取图像,并对其进行解码以保存在相应的目录中