Reputation: 552
I am using Spring Boot 2.6.4 and Spring Fox 3.0.0, I have a multipart file upload, but it is not appearing the button for uploading.
@PostMapping(consumes = "multipart/form-data")
public ResponseEntity<Object> addDocument(@RequestPart (value = "files", required = true) MultipartFile[] multipartFiles)
throws NoSuchAlgorithmException, IOException {
Here is how it appears on Swagger. Is it possible to use the button for uploading?
Upvotes: 2
Views: 8721
Reputation: 2512
Try to use MultipartFile
as a RequestParam
, (@RequestParam("attachments") MultipartFile[] attachments
)
@PostMapping(consumes = "multipart/form-data")
public ResponseEntity<Object> addDocument(@RequestParam ("files") MultipartFile[] multipartFiles) throws IOException {
}
_
Upvotes: 6
Reputation: 59
Did you try to include the type of parameter in the method? eg:
@PostMapping(consumes = "multipart/form-data")
public ResponseEntity<Object> addDocument(
@Parameter(
description = "Files to be uploaded",
content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE)
)
@RequestPart (value = "files", required = true) MultipartFile[] multipartFiles)
throws NoSuchAlgorithmException, IOException {
good coding! ¯_(ツ)_/¯
Upvotes: 1