mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
gridfs <- mongo.gridfs.create(mongo, "grid")
# Copy a local file to the server as a GridFS file
mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R")
# locate the file on the server
gf <- mongo.gridfs.find(gridfs, "test.R")
if( !is.null(gf)){
print(gf)
# and pipe it to an R connection object
test.R <- file("test2.R")
mongo.gridfile.pipe(gf, test.R)
mongo.gridfile.destroy(gf)
}
mongo.gridfs.destroy(gridfs)
}
Run the code above in your browser using DataLab