Utility function that supports easy file matching and download from a remote FTP server. Also enables on-the-fly file renaming and compression.

transmit(remoteDir, localDir = ".", pattern, rename = NULL, compress = FALSE)

Arguments

remoteDir

character(1). Remote FTP directory path.

localDir

character(1). Directory where to save files locally.

pattern

character(1). Pattern to use for matching.

rename

character(1) or NULL. Rename the local files (including suffix), if desired.

compress

logical(1). gzip compress the files after download.

Value

Invisible character. Local file paths.

Note

Updated 2020-01-30.

Examples

if ( goalie::hasInternet() && !isTRUE(nzchar(Sys.getenv("CI"))) ) { remoteDir <- paste( "ftp://ftp.ncbi.nlm.nih.gov", "genomes", "Homo_sapiens", sep = "/" ) readme <- transmit( remoteDir = remoteDir, pattern = "^README$", rename = "ncbi-readme.txt", compress = FALSE ) basename(readme) file.exists(readme) unlink(readme) }
#> Transmitting files from <ftp.ncbi.nlm.nih.gov>.
#> Files matching pattern: README
#> → Downloading ncbi-readme.txt.