gridfs {mongolite} | R Documentation

## GridFS API

### Description

Connect to a GridFS database.

### Usage

    gridfs(db = "test", url = "mongodb://localhost", prefix = "fs",
      options = ssl_options())

### Arguments

`db` | name of database
`url` | address of the mongodb server in mongo connection string URI format
`prefix` | string to prefix the collection name
`options` | additional connection options such as SSL keys/certs.

### Examples

    # New GridFS

    fs <- gridfs(url = "mongodb+srv://readwrite:test@cluster0-84vdt.mongodb.net/test")
    input <- R.home('doc/NEWS.pdf')
    fs$upload(input)
    fs$download('NEWS.pdf', 'output.pdf')
    hashes <- tools::md5sum(c(input, 'output.pdf'))
    unlink('output.pdf')
    stopifnot(hashes[[1]] == hashes[[1]])

    # Insert Binary Data
    fs$write('iris3', serialize(datasets::iris3, NULL))
    out <- fs$read('iris3')
    iris4 <- unserialize(out$data)
    stopifnot(all.equal(iris4, datasets::iris3))

    # Show what we have
    fs$find()
    fs$drop()

[Package mongolite version 1.6 Index]