I’m building a Spring Boot Controller with a @RequestParam array.
The thing is, the input will be a mix of Image upload (new image) and String (Existing image’s id) in the request’s body as FormData.
If, it is a new image, I have to upload the image and get it’s id.
If it is an existing image, I simply use the same id from the input.
In the controller, I tried using
@RequestParam Object[] images
and
if (images[i] instanceof String) {
// Existing Image
} else if (images[i] instanceof MultipartFile) {
// New Image
}
This works if all the items are images or all the items or string.
But, if it is a mixture of both, the Controller captures only the MultipartFile
When I check on the Network tab (Browser), all the String and Files are uploaded fine.
Can anyone help me with capturing the diferent types?