Issue
This Content is from Stack Overflow. Question asked by Dan
I am trying to upload a file using quarkus-resteasy-reactive-jackson
. Following different tutorials I seem to have everything setup as needed, but when I try to upload a file I get a 415 response code.
@Path("/companies/{companyId}/induction")
@Produces(MediaType.APPLICATION_JSON)
public class InductionController {
@Inject
InductionService service;
@POST
@Path("/{inductionId}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@PathParam("inductionId") Long inductionId,
@PathParam("companyId") Long companyId,
@MultipartForm InductionFile uploadedFile
) {
String fileLocation = "/uploads/" + companyId + "/" + StorageLocation.INDUCTION.getProperty() + "/" + inductionId;
// InductionEntity induction = service.saveFile(uploadedFile, inductionId, fileLocation);
return Response.ok().build();
}
}
public class InductionFile {
@FormParam("inductionFile")
@PartType(MediaType.APPLICATION_OCTET_STREAM)
public byte[] data;
}
2022-09-18 19:13:06,502 ERROR [io.bud.exc.map.ThrowableMapper] (executor-thread-0) errorId[fa42c898-c6f8-40e4-94c5-6975337f0526]: javax.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type
at org.jboss.resteasy.reactive.server.handlers.RequestDeserializeHandler.handle(RequestDeserializeHandler.java:59)
at org.jboss.resteasy.reactive.server.handlers.RequestDeserializeHandler.handle(RequestDeserializeHandler.java:25)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:548)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
This is my setup and it looks right to me, but it obviously isn’t. Can anyone shed any light on this for me?
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.