I have referred to this question, but still the answer is not clear.
Here's the scenarios where I am facing an issue:
@Consumes(MediaType.MULTIPART_FORM_DATA)
, we can only accept the file related data and it works fine. But when the request contains other details like name or phone number, the server throws "Unsupported Media Type" exception. How can we handle this scenario? We are using Jersey Rest and the front end sends AJAX requests.
Finally figured it out. We can access the additional attributes using @FormDataParam
itself. So, the method signature will look like -
public void createRecord(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("firstName") String firstName, @FormDataParam("lastName") String lastName)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.