Skip to content

Instantly share code, notes, and snippets.

@softberries
Created May 24, 2018 08:11
Show Gist options
  • Save softberries/e7b0c762fe344475d7b2bceba4be9285 to your computer and use it in GitHub Desktop.
Save softberries/e7b0c762fe344475d7b2bceba4be9285 to your computer and use it in GitHub Desktop.
extract image data from request
def checkFace(tempFolderPath: String, signInData: Option[MultipartFormData[TemporaryFile]], credentials: Credentials, user: User): Future[Boolean] = {
signInData.map { fileData =>
fileData.file("uploadedImage").map { image =>
import java.io.File
val filename = image.filename
image.ref.moveTo(new File(s"$tempFolderPath/signIn-$filename.png"))
val bos = new BufferedOutputStream(new FileOutputStream(new File(s"$tempFolderPath/orig-$filename.png")))
bos.write(user.face)
bos.close()
checkIfFacesMatch(s"$tempFolderPath/signIn-$filename.png", s"$tempFolderPath/orig-$filename.png")
}.getOrElse {
Future.successful(false)
}
}.get
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment