Reputation: 123
I'm upgrading one app to Mongo java driver 3.0.1. Everything works well except GridFs file saving. It works well with old java driver (2.12.4). Now I'm using mongodb-driver-core y mongodb-driver 3.0.1.
My code:
DB mongoDbFiles;
GridFS attachFile;
GridFSInputFile gfsFile;
mongoDbFiles = mongo.getDB("UserWebFiles");
attachFile = new GridFS(mongoDbFiles, "UserFiles");
..........
gfsFile = attachFile.createFile(new File("C:/dxl/" + (String) vFileNames.get(k)));
gfsFile.setFilename((String) vFileNames.get(k));
gfsFile.save();
In the save gives the error: com.mongodb.MongoException: couldn't save chunks
Caused by: java.io.IOException: Stream Closed
Has something changed with GridFs in the new drivers?
As I said it works well with driver 2.12.4. Java version 8 (jdk 1.8.0_25 - 32 bits)
Thanks in advance,
Augusto
Upvotes: 1
Views: 923
Reputation: 123
I found the problem in the mongo-driver-3.0.1.jar file. I corrected one of the GrisFS.createFile functions. I compiled again the jar file and now it works well.
If anyone has that problem I can send the jar file. I will try to send the correction to Mongo.
Upvotes: 2