This retrieves an object directly.

gcs_get_object(
  object_name,
  bucket = gcs_get_global_bucket(),
  meta = FALSE,
  saveToDisk = NULL,
  overwrite = FALSE,
  parseObject = TRUE,
  parseFunction = gcs_parse_download
)

Arguments

object_name

name of object in the bucket that will be URL encoded, or a gs:// URL

bucket

bucket containing the objects. Not needed if using a gs:// URL

meta

If TRUE then get info about the object, not the object itself

saveToDisk

Specify a filename to save directly to disk

overwrite

If saving to a file, whether to overwrite it

parseObject

If saveToDisk is NULL, whether to parse with parseFunction

parseFunction

If saveToDisk is NULL, the function that will parse the download. Defaults to gcs_parse_download

Value

The object, or TRUE if successfully saved to disk.

Details

This differs from providing downloads via a download link as you can do via gcs_download_url

object_name can use a gs:// URI instead, in which case it will take the bucket name from that URI and bucket argument will be overridden. The URLs should be in the form gs://bucket/object/name

By default if you want to get the object straight into an R session the parseFunction is gcs_parse_download which wraps httr's content.

If you want to use your own function (say to unzip the object) then supply it here. The first argument should take the downloaded object.

See also

Examples

if (FALSE) { ## something to download ## data.frame that defaults to be called "mtcars.csv" gcs_upload(mtcars) ## get the mtcars csv from GCS, convert it to an R obj gcs_get_object("mtcars.csv") ## get the mtcars csv from GCS, save it to disk gcs_get_object("mtcars.csv", saveToDisk = "mtcars.csv") ## default gives a warning about missing column name. ## custom parse function to suppress warning f <- function(object){ suppressWarnings(httr::content(object, encoding = "UTF-8")) } ## get mtcars csv with custom parse function. gcs_get_object("mtcars_meta.csv", parseFunction = f) }