Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

How to Send a List of Objects with MultipartFile[] and Metadata in a Single Request in Spring Boot

$
0
0

The official documentation describes what to do if you need to get both json and multipart data from a request:

@PostMapping("/")public String handle(@RequestPart("meta-data") MetaData metadata,        @RequestPart("file-data") MultipartFile file) {    // ...}

The official documentation describes what to do if I need to get both json and multipart data from a request. But what to do if i need an array of such objects?Can we make something like this work:

public record Data(MetaData metadata, List<MultipartFile> files) {}@PostMapping("/")public String handle(Set<Data> data) {    // ...}

Is it even possible? Or maybe some kind of workaround?And in the end how to test it using Postman?


Viewing all articles
Browse latest Browse all 675

Trending Articles