You should to write in your Auth method like this:
def IsAuthenticated[A](b: BodyParser[A])(f: => String => Request[AnyContent] => Future[SimpleResult]) =
Security.Authenticated(username, onUnauthorized) { user =>
Action.async { request =>
f(user)(request)
}
}
And then You may upload with this way in Controller:
def upload = IsAuthenticated(parse.temporaryFile) {_ => implicit request =>
val mfData = request.body.asMultipartFormData
Future.successful {
mfData.map { tempFile =>
tempFile.file("picture").map { file =>
val filePath = new File(".").getCanonicalPath() + "/test.png"
file.ref.moveTo(new File(filePath), true)
Logger.info("File successfully received to:" + filePath + " folder")
Ok("File uploaded")
}.getOrElse {
Redirect(routes.Application.uploadWindow()).flashing("error" -> "Missing file")
}
}.get
}
}