Question

I am trying to extract headers of each part in multipart request using Scala play. The inbuilt multipart handler parses data in Filepart. Filepart doesn't have any option to read individual headers of each part. It only has access to content type header.

Is there any ready to use API for this? OR is there simple way to handle it rather in writing a new custom BodyParser.

Was it helpful?

Solution

There is an overloaded form of the multiPartFormHandler method that takes a PartHandler:

type PartHandler[A] = PartialFunction[Map[String, String], Iteratee[Array[Byte], A]]

The Map[String, String] contains the headers. This saves you from having to write a whole new body parser, you only have to write this function that takes the headers and produces an Iteratee to consume the corresponding data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top