Created
January 21, 2013 23:46
-
-
Save sgodbillon/4590661 to your computer and use it in GitHub Desktop.
Upload a file into GridFS using Play2.1 and ReactiveMongo 0.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import play.api.mvc._ | |
import play.api.Play.current | |
import play.modules.reactivemongo._ | |
import customcommands._ | |
import reactivemongo.bson._ | |
import reactivemongo.bson.handlers.DefaultBSONHandlers._ | |
import play.api.libs.json._ | |
import reactivemongo.api.gridfs._ | |
object Application extends Controller with MongoController { | |
def gfs = GridFS(database) | |
def upload() = Action(gridFSBodyParser(gfs)) { request => | |
request.body.files.headOption.map { file => | |
Async { | |
file.ref.map { file => | |
Ok | |
} | |
} | |
}.getOrElse(BadRequest) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment