I try to do file upload from a JavaScript client to a JAX-RS Java server.
I use the following REST upload function on my server:
@POST
@Produces(\'ap
There is no Jax-RS way to do this. Each server have their own extensions, all using Multi-part form submissions. For example, in CXF, the following will allow you to upload via a multipart form. (Attachment is a CXF specific extension)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(@Multipart(value = "vendor") String vendor,
@Multipart(value = "uploadedFile") Attachment attr) {
whereas the following is the same for Jersey (FormDataParam is a Jersey extension):
@Consumes(MediaType.MULTIPART_FORM_DATA_TYPE)
public String postForm(
@DefaultValue("true") @FormDataParam("enabled") boolean enabled,
@FormDataParam("data") FileData bean,
@FormDataParam("file") InputStream file,
@FormDataParam("file") FormDataContentDisposition fileDisposition) {
(I've ignored the @Path, @POST and @Produces, and other non-relevant annotations.)