加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 播放2.5迁移错误:使用BodyParser自定义操作:找不到参

发布时间:2020-12-16 18:56:36 所属栏目:安全 来源:网络整理
导读:我有一个Play Framework应用程序,版本2.4迁移到2.5,一切都完成了!但在使用BodyParser的自定义操作中抛出错误, def isAuthenticatedAsync[A](parser: BodyParser[A])(f: = Long = Request[A] = Future[Result]) = {Security.Authenticated(userId,onUnauthor
我有一个Play Framework应用程序,版本2.4迁移到2.5,一切都完成了!但在使用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))
}

}

用这个:

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) =>

抛出错误:

could not find implicit value for parameter mat: akka.stream.Materializer

[error] def upload = Action.async(parse.maxLength(5 * 1024 * 1024,parse.multipartFormData)){request =>

解决方法

看起来你需要在控制器中注入一个物质化器

class MyController @Inject() (implicit val mat: Materializer) {}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读