# NOT RUN {
# }
# 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.csv", parseFunction = f)
## download an RDS file using helper gcs_parse_rds()
gcs_get_object("obj.rds", parseFunction = gcs_parse_rds)
## to download from a folder in your bucket
my_folder <- "your_folder/"
objs <- gcs_list_objects(prefix = my_folder)
dir.create(my_folder)
# download all the objects to that folder
dls <- lapply(objs$name, function(x) gcs_get_object(x, saveToDisk = x))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab