Skip to content

Instantly share code, notes, and snippets.

@jkyamog
Created May 29, 2013 22:09
Show Gist options
  • Save jkyamog/5674235 to your computer and use it in GitHub Desktop.
Save jkyamog/5674235 to your computer and use it in GitHub Desktop.
reactive mongo using gridfs to list files
import reactivemongo.api.gridfs.Implicits._
def listFiles(docId: String) = Action {
Async {
listOfFiles(docId).map (files => Ok(files))
}
}
def listOfFiles(docId: String) = {
val files = gridFS.find(BSONDocument("document" -> new BSONObjectID(docId)))
files.toList.map { files =>
val filesId = files map (file => bsonToString(file.id))
Json.toJson(Map("files" ->filesId))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment