Description Usage Arguments Details Value See Also Examples
Store raw data as a file to a GridFS on a MongoDB server. This function stores the entire piece of data file on the server, breaking it up into 256K chunks as necessary.
1 | mongo.gridfs.store(gridfs, raw, remotename, contenttype = "")
|
gridfs |
A (mongo.gridfs) object. |
raw |
(raw) The data to store on the server. |
remotename |
(string) The name the file will be known as within the GridFS. |
contenttype |
(string) Optional MIME content type. |
This function only handles the RAW type. Use writeBin()
as necessary
to pack your data appropriately for storage. See the examples and R's
documentation on writeBin()
.
Use mongo.gridfile.writer when you need to buffer many writes to a GridFS file.
TRUE, if successful; FALSE, if an error occured during the operation.
mongo.gridfs,
mongo.gridfs.create
,
mongo.gridfs.remove.file
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.