def doUpload = Action.async(parse.multipartFormData) { request=>
import reactivemongo.api.gridfs.Implicits._
request.body.file("photo").map { file =>
val db = reactiveMongo.connection("photo")
val gridFs = GridFS[BSONSerializationPack.type](db)
gridFs.save(Enumerator.fromFile(file.ref.file), DefaultFileToSave(file.filename, file.contentType)).map {
readFile =>
Ok(s"${readFile.id.toString} ${readFile.filename} ${readFile.length}")
}
}.getOrElse {
Ok("Notfound").fuSuccess
}
}
Error
Execution exception
[ConnectionNotInitialized: MongoError['Connection is missing metadata (like protocol version, etc.) The connection pool is probably being initialized.']]
reactivemongo.core.errors.ConnectionNotInitialized: MongoError['Connection is missing metadata (like protocol version, etc.) The connection pool is probably being initialized.']
at reactivemongo.core.errors.ConnectionNotInitialized$.MissingMetadata(errors.scala:67) ~[reactivemongo_2.11-0.11.6.jar:0.11.6]
at reactivemongo.api.collections.GenericCollection$$anonfun$insert$1.apply(genericcollection.scala:271) ~[reactivemongo_2.11-0.11.6.jar:0.11.6]
at reactivemongo.api.collections.GenericCollection$$anonfun$insert$1.apply(genericcollection.scala:253) ~[reactivemongo_2.11-0.11.6.jar:0.11.6]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[scala-library-2.11.6.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[scala-library-2.11.6.jar:na]