I have a Play Framework application, version 2.4 migrating to 2.5, everything done ! but throw an error in my custom action with BodyParser,
def isAuthenticatedAsync[A](parser: BodyParser[A])(f: => Long => Request[A] => Future[Result]) = {
Security.Authenticated(userId, onUnauthorized) { user =>
Action.async(parser)(request => f(user)(request))
}
}
Use this:
def upload = isAuthenticatedAsync(parse.maxLength(5 * 1024 * 1024, parse.multipartFormData)) { userId => request =>
//Logger.info(s"")
request.body match {
case Left(MaxSizeExceeded(length)) => Future(BadRequest(Json.toJson(ResultTemp("Your file is too large, we accept just " + length + " bytes!"))))
case Right(multipartForm) =>
throw an error:
could not find implicit value for parameter mat: akka.stream.Materializer
[error] def upload = Action.async(parse.maxLength(5 * 1024 * 1024, parse.multipartFormData)) { request =>
Looks like you need to inject a materializer in your controller
class MyController @Inject() (implicit val mat: Materializer) {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With