jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
286 stars 65 forks source link

mongolite can't read GridFS when mongo java driver has saved GridFS data #165

Open rtreacy opened 5 years ago

rtreacy commented 5 years ago

I have a Java application that writes data to GridFs that I need to use in R. I have been using rmongodb up to now and it has no problem with the Java application data. I need to replace the rmongodb library with mongolite, as rmongodb is outdated and not being actively maintained. However, mongolite seems to have a problem with the data from the Java Mongo driver. -I was using sample code to insert data with mongolite as below: con2 <- url('https://cloud.r-project.org/src/base/R-3/R-3.5.1.tar.gz') fs$write(con2, 'source.tar.gz', progress = FALSE, metadata = '{"This is" : "just a test"}') -and would then see:

fs$find() [1] id name size date type metadata

<0 rows> (or 0-length row.names)

-when I run db.fs.files.find() in the mongo command line client, I can see both the mongolite and the Java app data

-However if I went into my Java application and removed the GridFS data I had created there I could see things created in mongolite --

fs$find() id name size 4 5c095ea5f69f56eaef5863b2 source2.tar.gz 29812849 5 5c095f45f69f56eaef5863b5 source2.tar.gz 29812849 6 5c0974cff69f560a141615b4 source.tar.gz 29812849 date type metadata 4 2018-12-06 17:38:45 { "This is" : "just a test" } 5 2018-12-06 17:41:25 { "This is" : "just a test" } 6 2018-12-06 19:13:19 { "This is" : "just a test" }

-Then recreating the Java data and then removing it again, performing fs$find in between // recreate the Java app data and neither the Java data or the mongolite data is visible --

fs$find() [1] id name size date type metadata

<0 rows> (or 0-length row.names)

//remove Java app data again and the mongolite data reappears --

fs$find() id name size 4 5c095ea5f69f56eaef5863b2 source2.tar.gz 29812849 5 5c095f45f69f56eaef5863b5 source2.tar.gz 29812849 6 5c0974cff69f560a141615b4 source.tar.gz 29812849 date type metadata 4 2018-12-06 17:38:45 { "This is" : "just a test" } 5 2018-12-06 17:41:25 { "This is" : "just a test" } 6 2018-12-06 19:13:19 { "This is" : "just a test" }