Hi.
My system is writen on php and java.
I started testing php and java drivers to communicate with GridFs.
I can store and get files with php, and so with java, but
when I store a file with php in GridFs and then want to get and write it to fs with java it fails:
java.lang.ClassCastException: org.bson.types.Binary cannot be cast to [B
at com.mongodb.gridfs.GridFSDBFile.getChunk(GridFSDBFile.java:89)
at com.mongodb.gridfs.GridFSDBFile.writeTo(GridFSDBFile.java:75)
but when with java and then with php, everything ok.
sample code i am using:
PHP WRITE CODE
$m = new Mongo();
$fs = $m->test->getGridFs();
echo $fs->storeFile("J:
1.avi", array('filename' => 'filename1'), array('safe' => true));
JAVA READ CODE
GridFS myFS;
try {
myFS = new GridFS(new Mongo().getDB("test"));
GridFSDBFile f = myFS.findOne("filename1");
if(f!=null)
else
{ System.out.println("false"); }
} catch (Exception ex)
ps
I danced a lot with this code, modified parameters, changed ids, php and java drivers on older versions. Nothing helped.
And java gets file by id fine, but when saving getting exception.
What I am doing wrong ?
Thanks.
- depends on
-
JAVA-368 When reading back binary of type B_GENERAL (2) Java driver creates a Binary object which breaks some driver and user code
- Closed