Hi all,
I am trying to download a file from GridFS using MongoDB Java Driver 3.4.
I know the ID of the file, so I simply do:
GridFSBucket gridFSFilesBucket = GridFSBuckets.create(db);
GridFSFile file = gridFSFilesBucket.find(eq("_id", fileId)).first();
But it throws the exception:
Exception in thread "main" org.bson.BsonInvalidOperationException: Document does not contain key filename
at org.bson.BsonDocument.throwIfKeyAbsent(BsonDocument.java:844)
at org.bson.BsonDocument.getString(BsonDocument.java:233)
at com.mongodb.client.gridfs.codecs.GridFSFileCodec.decode(GridFSFileCodec.java:68)
at com.mongodb.client.gridfs.codecs.GridFSFileCodec.decode(GridFSFileCodec.java:48)
at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52)
I encounter the same issue if I try to use downloadToStream.
Is it a bug in the API ?
Cheers,