I'm trying to do a file upload for my Errai app, however I'm getting this error:
[INFO] DEBUG [SynchronousDispatcher] PathInfo: /blob
[INFO] WARN [ExceptionHandler] Failed executing GET /blob
[INFO] org.jboss.resteasy.spi.NotAcceptableException: No match for accept header
[INFO] at org.jboss.resteasy.core.registry.Segment.match(Segment.java:119)
[INFO] at org.jboss.resteasy.core.registry.PathParamSegment.matchPattern(PathParamSegment.java:200)
[INFO] at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:339)
The Errai service looks like this:
@Path("blob")
public interface BlobService {
@GET
@Produces(MediaType.TEXT_PLAIN)
String getBlobStoreUploadUrl(); // return "/blob/upload"
@GET
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
Picture getPicture(@PathParam("id") String id);
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
void uploadPicture();
}
Now, upload is triggered this way:
submitButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent e) {
blobService.call(new RemoteCallback<String>() {
@Override
public void callback(String response) {
uploadForm.setAction(response);
uploadForm.submit();
uploadForm.reset();
}
}).getBlobStoreUploadUrl();
}
});
From what it seems there a discrepancy on how I did file upload. The idea here is just to upload the file selected in the usual upload form to the uploadPicture
method.
What could be wrong in the way I coded the upload service?
have you set the mime type on the form? like so