Scala 如何使用reactivemongo覆盖Play框架内的gridfs文件?
我有以下代码来编写gridfs文件:Scala 如何使用reactivemongo覆盖Play框架内的gridfs文件?,scala,playframework,playframework-2.0,reactivemongo,mongodb-scala,Scala,Playframework,Playframework 2.0,Reactivemongo,Mongodb Scala,我有以下代码来编写gridfs文件: request.body.files.toList.lastOption match { case Some(picture) => { val filename = picture.filename val contentType = picture.contentType picture.ref.moveTo(new File("/tmp/" + filename), true) val
request.body.files.toList.lastOption match {
case Some(picture) => {
val filename = picture.filename
val contentType = picture.contentType
picture.ref.moveTo(new File("/tmp/" + filename), true)
val gridFS = new GridFS(db, "attachments")
val fileToSave = DefaultFileToSave(filename, contentType)
val futureResult: Future[ReadFile[BSONValue]] = gridFS.writeFromInputStream(fileToSave, new FileInputStream(new File("/tmp/" + filename)))
...
代码运行良好,但当我编写两个同名文件时,它会复制集合中的文件。我想用filename字段创建一个唯一的索引,但这样会保留第一个文件,我需要保留最新版本。我怎么做
谢谢
GA