gcs_cp {GCSConnection} | R Documentation

## copy files to and from buckets

### Description

The function supports moving files or folders from bucket to bucket, disk to bucket and bucket to disk. Note that the existing destination file will be overwritten.

### Usage

    gcs_cp(from, to, recursive = TRUE)

### Arguments

`from, to` | Character(1). The path to the folder/file. At least one path must be a google URI. It is recommended to explicitly add a "/" at the end of the path if the path is a folder path.
`recursive` | logical(1). Whether recursively copy the files in the subfolders.

### Value

No return value

### Examples

    tmp_path <- tempdir()
    ## Download a file to a disk
    gcs_cp("gs://genomics-public-data/NA12878.chr20.sample.bam", tmp_path)
    ## Check the file existance
    file.exists(file.path(tmp_path, "NA12878.chr20.sample.bam"))

    ## Download all files in a path.
    ## The files in the subfolders will not be copied due to `recursive = FALSE`
    folder_path <- file.path(tmp_path, "example")
    gcs_cp("gs://genomics-public-data/", folder_path, recursive = FALSE)
    ## Check the file existance
    list.files(folder_path)

[Package GCSConnection version 1.0.1 Index]