I'm using Play 2.1.1 with Scala and have a controller to deal with file uploads, specifically images. Locally this works perfectly, however, I have now deployed a war file using play2-war-plugin (https://github.com/dlecan/play2-war-plugin) to a server running ubuntu and tomcat7.
Now when I upload an image I get the following exception
[ScalaIOException: MainException: class java.io.IOException(No such file or directory)]
My controller is
def addProjectImage(id: Long) = Action(parse.multipartFormData) { implicit request =>
DB.withSession{ implicit session => {
request.body.file("img").map { picture =>
import java.io.File
val filename = picture.filename + ".png"
val contentType = picture.contentType
var f = new File(s"./public/upload/project_picture/${filename}")
picture.ref.moveTo(f)
Projects.updateImage(id, "/assets/upload/project_picture/"+filename)
Redirect(routes.Admin.index)
}.getOrElse {
Redirect(routes.Application.index).flashing(
"error" -> "Missing image"
)
}
}}
}
Any suggestions would be really appreciated.
Thanks in advance.