def importFromTaleo: Action[MultipartFormData[Files.TemporaryFile]] = Action()

in app/controllers/Application.scala [70:109]


  def importFromTaleo: Action[MultipartFormData[Files.TemporaryFile]] = Action(parse.multipartFormData) { implicit request =>
    request.body.file("pdf").map { pdf =>
      val candidates = PdfRedactor.candidates(pdf.ref)
      val doc = PDDocument.load(pdf.ref)
      val docs = PdfRedactor.splitCandidates(doc, candidates)
      val uploadedFilename = Paths.get(pdf.filename).getFileName.toString
      val filename = uploadedFilename.replace(".pdf", "-anon.zip")

      val stream = StreamConverters.asOutputStream().mapMaterializedValue { outputStream =>
        Future {
          val zos = new ControlledCloseZipOutputStream(outputStream) 

          docs.foreach { case (candidate, doc) =>
            val entryName = s"anon-candidates/${candidate.id}-redact.pdf"
            zos.putNextEntry(new ZipEntry(entryName))
            try {
              candidate.firstName.split(" ").toList
              PdfRedactor.redact(doc, zos, splitName(candidate.firstName) ++ splitName(candidate.lastName))
              doc.close()
            } catch {
              case e: Exception => logger.error("Oops", e)
            }
            zos.closeEntry()
          }
          doc.close()

          zos.putNextEntry(new ZipEntry("anon-candidates/candidates.csv"))
          candidates.foreach { c =>
            zos.write(List(s"${c.lastName}, ${c.firstName}", c.id, c.jobText, c.jobId).map(quoteString).mkString("", ",", "\n").getBytes)
          }
          zos.closeEntry()
          zos.closeNow()
        }
      }
      Ok.chunked(stream).withHeaders("Content-Disposition" -> s"inline; filename=$filename")
    }.getOrElse {
      Redirect(routes.Application.index()).flashing(
        "error" -> "Missing file")
    }
  }