Can I have a rest service that can be used for file upload i.e. multi-part form data and JSON parameter? Below is the example of the service.
@POST
@Path("/upload")
@Consumes({ MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_JSON })
public Response uploadFile(@FormDataParam("file") InputStream uploadedInputStream,@FormDataParam("file") FormDataContentDisposition fileDetail, City city){
The problem is while testing I am trying to pass both file as an attachment and city object as JSON, it is giving me error as Content-Type could either be application/json
or multipart/form-data
.
Let me know if there is any way to handle this