D_K
D_K

Reputation: 65

reading header of each part in multipart request in Scala Play

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.

Upvotes: 0

Views: 333

Answers (1)

wingedsubmariner
wingedsubmariner

Reputation: 13667

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.

Upvotes: 1

Related Questions