mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
gridfs <- mongo.gridfs.create(mongo, "grid")
# store 4 bytes
mongo.gridfs.store(gridfs, charToRaw("test"), "test4.dat")
# store string & LF plus 0-byte terminator
buf <- writeBin("Test\n", as.raw(1))
mongo.gridfs.store(gridfs, buf, "test6.dat")
# store PI as a float
buf <- writeBin(3.1415926, as.raw(1), size=4, endian="little")
mongo.gridfs.store(gridfs, buf, "PI.dat")
mongo.gridfs.destroy(gridfs)
}
Run the code above in your browser using DataLab