Skip to content

Instantly share code, notes, and snippets.

@lazyval
Created May 11, 2012 20:07
Show Gist options
  • Save lazyval/2662149 to your computer and use it in GitHub Desktop.
Save lazyval/2662149 to your computer and use it in GitHub Desktop.
Casbah's GridFS upsert operation
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