0
votes

I have been trying to send file from rest client to my spring controller. In controller I have used "@requestParam("file") MultipartFile file" to get the file from client and annotated with REST service annotations like below

@Override
    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
//  @Path("/FinancePdf")
    @ApiOperation(value = "save finance pdf")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success",response = String.class),
    })

    public @ResponseBody  String saveFinancePdf(@RequestParam("file") MultipartFile file)
    {
        return "done";
    }

I am always getting 415 Media type not support. in the above method, if I not give the multipart it's giving me the result as done but not with the multipart.

so may I know how to send file from to my spring controller?

1

1 Answers

0
votes

Try using @FormDataParam and stream the file.

public @ResponseBody String saveFinancePdf(
@FormDataParam("file") InputStream in,
@FormDataParam("file") FormDataContentDisposition fileDisposition ){
     return "done";
}