rmongodb (version 1.8.0)

mongo.gridfs.store.file: Store a file into a GridFS on a MongoDB server

Description

Store a file into a GridFS on a MongoDB server. This function stores the entire given file on the server, breaking it up into 256K chunks as necessary.

Usage

mongo.gridfs.store.file(gridfs, filename, remotename = "", contenttype = "")

Arguments

gridfs
A (mongo.gridfs) object.
filename
(string) The path/filename of the file to copy to the server.
remotename
(string) The name the file will be known as within the GridFS. If remotename=="" (the default), the remote file will be known by the given filename.
contenttype
(string) Optional MIME content type.

Value

TRUE, if successful; FALSE, if an error occured during the operation.

See Also

mongo.gridfs, mongo.gridfs.create, mongo.gridfs.remove.file.

Examples

Run this code
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")
    mongo.gridfs.destroy(gridfs)
}

Run the code above in your browser using DataLab