0

I need to upload a file from Quarkus application to jesrey 2 rest service which is expecting two params like

@FormDataParam("file") InputStream uploadFileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData

Used below code in Quarkus to send file

public class MultipartBody {

    @FormParam("file")
    @PartType(MediaType.APPLICATION_OCTET_STREAM)
    public InputStream file;

    @FormParam("fileName")
    @PartType(MediaType.TEXT_PLAIN)
    public String fileName;
}

@RegisterRestClient
public interface MultipartService {

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.TEXT_PLAIN)
    String sendMultipartData(@MultipartForm MultipartBody data);

}

I'm getting 500 error while calling the service. In service side logs, it says fileMetaData is null

  • Can you use Wireshark (or similar) to see what the client is sending? – geoand Jun 09 '21 at 19:20
  • you should probably add a header factory to the rest client, it could be a missing boundary setting in the Content-Type header which from your code I am not sure is being set, see @antichris answer https://stackoverflow.com/questions/3508338/what-is-the-boundary-in-multipart-form-data – Nigel Savage Jun 11 '21 at 17:26

0 Answers0