I'm creating an api for sending email in Spring Boot. I can successfully send an attachment in email using the following api
@PostMapping("/send")
public void sendMail(@RequestParam(value = "receiver") String receiver,
@RequestParam(value = "subject") String subject, @RequestParam(value = "content") String content,
@RequestParam(value = "file", required = false) MultipartFile file) {
mailService.send(receiver, subject, content, file);
}
But an email can have multiple attachments. So, using this link as the reference, I updated my code to
@PostMapping("/send")
public void sendMail(@RequestParam(value = "receiver") String receiver,
@RequestParam(value = "subject") String subject, @RequestParam(value = "content") String content,
@RequestParam(value = "files", required = false) MultipartFile[] files) {
mailService.send(receiver, subject, content, files);
}
With this in place, I can add multiple images from the Swagger UI
Update: I get the following form in Swagger from which I can upload images
But when I submit the form, I found that the value in files is now null instead of an array of files.
What am I missing?