gcs_get_object

Get an object in a bucket directly

This retrieves an object directly.

Usage
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
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.

Value

The object, or TRUE if successfully saved to disk.

See Also

Other object functions: gcs_delete_object, gcs_list_objects, gcs_metadata_object

Aliases
  • gcs_get_object
Examples

## Not run: ------------------------------------
# 
# ## 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)
# 
## ---------------------------------------------

Documentation reproduced from package googleCloudStorageR, version 0.3.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.