gcs_connection {GCSConnection} | R Documentation |
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'. If the bucket requires Requester Pays, a billing project needs to be set in 'gcs_set_billing_project'.
gcs_connection( description, open = "rb", encoding = getOption("encoding"), bucket = NULL, billing_project = gcs_get_requester_pays() )
description |
A google uri to the file that you want to connect to or a FileClass object returned by 'gcs_dir'. If the value is a path(e.g. "folder1/folder2/myfile") and the argument 'bucket' is missing, it will be treated as a google uri without the common header 'gs://'. If the argument 'bucket' is not missing, the value in 'description' will be treated as a relative path. |
open |
character(1). A description of how to open the connection. See details for possible values. the default is "rb". |
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 a google uri to the file is provided in 'description', this parameter will be ignored. |
billing_project |
logical(1) or character(1). If logical, whether users should pay the cost for accessing the data. The billing project is the project ID in 'gcs_get_billing_project()'. If character, it represents the project ID that will be charged by Google. |
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.
A connection
## Open for reading the public Landsat data # on google cloud ## storage in text mode f <- "gs://genomics-public-data/NA12878.chr20.sample.DeepVariant-0.7.2.vcf" con <- gcs_connection(description = f, open = "rt") readLines(con, n = 4L) close(con)