Skip to content

Commit

Permalink
Drop deprecated @MultipartForm annotation, it is surplus to requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Dec 22, 2022
1 parent 18c48ee commit a3d897a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,38 @@
import javax.ws.rs.core.MediaType;

import org.apache.commons.io.IOUtils;
import org.jboss.resteasy.reactive.MultipartForm;

@Path("/multipart")
public class MultipartResource {

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.MULTIPART_FORM_DATA)
public MultipartBody postForm(@MultipartForm MultipartBody multipartBody) {
public MultipartBody postForm(MultipartBody multipartBody) {
return multipartBody;
}

@POST
@Path("/text")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public String postFormReturnText(@MultipartForm MultipartBody multipartBody) {
public String postFormReturnText(MultipartBody multipartBody) {
return multipartBody.text;
}

@POST
@Path("/image")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public byte[] postFormReturnFile(@MultipartForm MultipartBody multipartBody) throws IOException {
public byte[] postFormReturnFile(MultipartBody multipartBody) throws IOException {
return IOUtils.toByteArray(multipartBody.image.toURI());
}

@POST
@Path("/data")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public byte[] postFormReturnData(@MultipartForm MultipartBody multipartBody) throws IOException {
public byte[] postFormReturnData(MultipartBody multipartBody) throws IOException {
return IOUtils.toByteArray(multipartBody.data.toURI());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import javax.ws.rs.core.MediaType;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import org.jboss.resteasy.reactive.MultipartForm;

@Path("/multipart/echo")
@RegisterRestClient
Expand All @@ -16,5 +15,5 @@ public interface MultipartService {
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
String sendMultipartData(@MultipartForm ClientMultipartBody data);
String sendMultipartData(ClientMultipartBody data);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import org.jboss.resteasy.reactive.MultipartForm;

import io.smallrye.mutiny.Uni;

Expand Down Expand Up @@ -50,6 +49,6 @@ public interface FileClient {
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
@Path("/upload-multipart")
String sendMultipart(@MultipartForm FileWrapper data);
String sendMultipart(FileWrapper data);

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import javax.ws.rs.core.MediaType;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.resteasy.reactive.MultipartForm;
import org.jboss.resteasy.reactive.RestResponse;

import io.quarkus.logging.Log;
Expand Down Expand Up @@ -61,7 +60,7 @@ public Uni<String> upload(File body) {
@Produces(MediaType.TEXT_PLAIN)
@Path("/upload-multipart")
@Blocking
public String uploadMultipart(@MultipartForm FileWrapper body) {
public String uploadMultipart(FileWrapper body) {
deathRow.add(body.file);
return utils.getSum(body.file.getAbsoluteFile().toPath());
}
Expand Down

0 comments on commit a3d897a

Please sign in to comment.