简体   繁体   中英

MongoDb 3.0.1 java driver GridFs error

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM