Created
May 11, 2012 20:07
-
-
Save lazyval/2662149 to your computer and use it in GitHub Desktop.
Casbah's GridFS upsert operation
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
private def upsert(filename: String, extension: String, is: InputStream) { | |
gridfs.findOne(filename) match { | |
case Some(_) => println(filename + " is already in database") | |
case None => | |
gridfs(is) { | |
file => | |
file.filename = filename | |
file.contentType = "image/" + extension | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment