gcs_connection {GCSConnection} | R Documentation

## Connection to google cloud storage

### Description

This function creates an R connection to a file on google cloud storage. A service account credentials is required for accessing private data, the credentials can be set via 'gcs_cloud_auth'

### Usage

    gcs_connection(
      description,
      open = "rb",
      encoding = getOption("encoding"),
      bucket = NULL
    )

### Arguments

`description` | character(1). The name of the file that you want to connect to. It can be either the file name or a full path to the file.
`open` | character(1). A description of how to open the connection. See details for possible values. If not specified, the default value will be "rb" if a credential is set or "rbp" if not.
`encoding` | character(1). The encoding of the input/output stream of a connection. Currently the parameter 'encoding' should be either 'native.enc' or 'UTF8'. see '?connections' for more detail.
`bucket` | character(1). The name of the bucket that the file is located in. If not supplied, value in 'gcs_get_global_bucket()' will be used. If a full path to the file is provided in 'description', this parameter will be ignored.

### Details

Possible values for the argument 'open' are the combination of the following characters:

"r" or "w" : read or write mode. The GCS connection cannot be in both read and write modes.

"t" or "b" : text or binary mode. If not specified, the default is text mode.

### Value

A connection

### Examples

    ## Open for reading the public Landsat data
    ## on google cloud storage in text mode

    file <- "gs://genomics-public-data/NA12878.chr20.sample.DeepVariant-0.7.2.vcf"
    con <- gcs_connection(description = file, open = "rt")
    readLines(con, n = 4L)
    close(con)

[Package GCSConnection version 1.0.1 Index]