2

我正在将 Mongodb/Morphia 与 Play 2.0.4 和 Play2 Morphia 插件一起使用(据我所知,这实际上只是 Morphia 的一个包装器 - https://github.com/leodagdag/play2-morphia-plugin)。

当我上传显示图片时,我将其与对象一起保存,如下所示:

MultipartFormData body = request().body().asMultipartFormData();
FilePart picture = body.getFile("thumbnail");
if (picture != null) {
    File file = picture.getFile();
    obj.setThumbnailUpload(file);
}
obj.save();

这将在我第一次上传文件时起作用。但是,当我随后在不更新图片的情况下重新保存交易时,它会说它丢失了一大块。我需要做什么才能不覆盖 blob?

[ERROR] [10/19/2012 00:04:24.640] [promise-akka.actor.default-dispatcher-170] [akka.dispatch.Dispatcher] can't find a chunk!  file id: 507f89250364707ed55a816f chunk: 0
com.mongodb.MongoException: can't find a chunk!  file id: 507f89250364707ed55a816f chunk: 0
    at com.mongodb.gridfs.GridFSDBFile.getChunk(GridFSDBFile.java:103)
    at com.mongodb.gridfs.GridFSDBFile$MyInputStream.read(GridFSDBFile.java:151)
    at com.mongodb.gridfs.GridFSDBFile$MyInputStream.read(GridFSDBFile.java:142)
    at play.api.libs.iteratee.Enumerator$$anonfun$fromStream$2.apply(Iteratee.scala:980)
    at play.api.libs.iteratee.Enumerator$$anonfun$fromStream$2.apply(Iteratee.scala:978)
    at play.api.libs.iteratee.Enumerator$$anon$17$$anonfun$22.apply(Iteratee.scala:949)
    at play.api.libs.iteratee.Enumerator$$anon$17$$anonfun$22.apply(Iteratee.scala:948)
    at play.api.libs.iteratee.Cont$$anon$21.fold(Iteratee.scala:341)
    at play.api.libs.iteratee.Iteratee$$anon$18$$anonfun$fold$1.apply(Iteratee.scala:16)
    at play.api.libs.iteratee.Iteratee$$anon$18$$anonfun$fold$1.apply(Iteratee.scala:16)
    at play.api.libs.concurrent.AkkaPromise$$anonfun$flatMap$1.apply(Akka.scala:58)
    at play.api.libs.concurrent.AkkaPromise$$anonfun$flatMap$1.apply(Akka.scala:57)
    at akka.dispatch.Future$$anonfun$onSuccess$1.apply(Future.scala:484)
    at akka.dispatch.Future$$anonfun$onSuccess$1.apply(Future.scala:483)
    at akka.dispatch.KeptPromise$$anonfun$onComplete$2.apply$mcV$sp(Future.scala:956)
    at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply$mcV$sp(Future.scala:386)
    at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply(Future.scala:378)
    at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply(Future.scala:378)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
    at akka.dispatch.Future$$anon$4.run(Future.scala:378)
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:94)
    at akka.jsr166y.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1381)
    at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259)
    at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
    at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479)
    at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)

谢谢史蒂夫

4

0 回答 0