Does the vert.x adapter support multipart body?

I have a file upload endpoint that accepts multiple files from different types.

case class FileUpload(files: List[Part[File]])

val fileUploadEndpoint: SecuredEndpoint[FileUpload, List[
  Either[FileUploadError, String]
] | String, List[String], Any] =
  auth.securedWithBearer.post
    .in("upload")
    .in(multipartBody[FileUpload])
    .out(jsonBody[List[String]])
    .mapErrorOut(identity)(_.toString())

And a server logic that receives the list of Part[File] that uses the contentType to process the file accordingly

def extractText(
    file: Part[File]
): IO[Either[ExtractTextError, String]] =
  val body = Files.readAllBytes(file.body.toPath)
  val name = file.fileName

  file.contentType match
    case Some("application/pdf") => ...make format-specific parsing...

It works as expected with Http4sServerInterpreter, but not with VertxCatsServerInterpreter because the file.contentType is always None.

Can you create a bug report? I think here we should also extract the content-type and other headers and pass them to the Part constructor

1 Like