It's been a few months since I started learning scala+play.
I'm trying to implement fileupload, and I'd like to have a view that displays identity using silhouette, but I don't know how to write it.
The methods in question are as follows:
Sample fileupload found in official github
https://github.com/playframework/play-scala-fileupload-example/tree/2.5.x
silhouette 4.0.0
https://github.com/mohiva/play-silhouette-seed/tree/4.0.0/app
default=Action(parse.multipartFormData(handleFilePartAsFile)) {implicit request=>
valfileOption=request.body.file("picName").map{
caseFilePart(key, filename, contentType, file)=>
logger.info(s"key=${key}, filename=${filename}, contentType=${contentType}, file=$file")
valdata=operateOnTempFile(file)
data
}
FileUploadFormSupport.picsave(_)
silhouette.SecuredAction.async {implicit request=>
Future.successful(Ok(views.html.fileUpload2(request.identity,fileOption)))
}
}
silhouette.SecuredAction.async {implicit request=>
Future.successful(Ok(views.html.fileUpload2(request.identity,fileOption)))
}
I thought I should just put this part in the upload method, so I did my best.
missing parameter type
You will see an error.
Also, I tried rewriting the request as request:Request, but I got an error saying that there were no type parameters.I'm trying to figure out how to write it, but I haven't found it yet.
scala playframework
The English version solved the problem.Thank you.
You pointed out that it should be written as follows.
default=
silhouette.SecuredAction.async(parse.multipartFormData(handleFilePartAsFile)){
implicit request=>
// Your upload code
}
© 2024 OneMinuteCode. All rights reserved.