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, billing_project = gcs_get_requester_pays())

### Arguments

`from, to` | the character path to a bucket/folder/file or a FolderClass/FileClass object returned by 'gcs_dir'. At least one path must be a google URI. It is recommended to explicitly add a trailing "/" if the parameter is a path to a folder.
`recursive` | logical(1). Whether to recursively copy the files in the subfolders.
`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.

### 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.2.0 Index]