Learn R Programming

rmongodb (version 1.8.0)

mongo.gridfile.writer.finish: Finish writing to a buffered GridFS file

Description

Finish writing to a buffered GridFS file. This function flushes any partial buffer and finalizes the operation.

Usage

mongo.gridfile.writer.finish(gfw)

Arguments

gfw

Value

TRUE, if successfil; false, if an error occurred.

See Also

mongo.gridfs, mongo.gridfile.writer.create, mongo.gridfile.writer, mongo.gridfile.writer.write.

Examples

Run this code
mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
    gridfs <- mongo.gridfs.create(mongo, "grid")

    gfw <- mongo.gridfile.writer.create(gridfs, "test.dat")

    # store 4 bytes
    mongo.gridfile.writer.write(gfw, charToRaw("test"))

    # store string & LF plus 0-byte terminator
    buf <- writeBin("Test\n", as.raw(1))
    mongo.gridfile.writer.write(gfw, buf)

    # store PI as a float
    buf <- writeBin(3.1415926, as.raw(1), size=4, endian="little")
    mongo.gridfile.writer.write(gfw, buf)

    mongo.gridfile.writer.finish(gfw)
    mongo.gridfs.destroy(gridfs)
}

Run the code above in your browser using DataLab