(refs #28)Implementing avatar image uploading.

This commit is contained in:
takezoe
2013-07-10 03:01:46 +09:00
parent 09ef1e0319
commit 2c33abe5d1
3 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package app
import org.scalatra._
import org.scalatra.servlet.{MultipartConfig, FileUploadSupport}
/**
* Provides Ajax based file upload functionality.
*
* This servlet saves uploaded file as temporary file and returns the unique key.
* You can get uploaded file using [[app.FileUploadUtil#getFile()]] with this key.
*/
// TODO Remove temporary files at session timeout by session listener.
class FileUploadController extends ScalatraServlet with FileUploadSupport with FlashMapSupport {
configureMultipartHandling(MultipartConfig(maxFileSize = Some(3*1024*1024)))
post("/"){
fileParams.get("file") match {
// TODO save as temporary file and return key.
case Some(file) => {
println(file.name)
println(file.size)
Ok("1234")
}
case None => BadRequest
}
}
}
// TODO Not implemented yet.
object FileUploadUtil {
def getFile(key: String) = {
}
}