sftp_download: Download files from an SFTP account

View source: R/sftp.R

sftp_downloadR Documentation

Download files from an SFTP account

Description

This function is used for downloading files from an SFTP account. The function uses connection credentials from a list object created by calling sftp_connect. The files will be downloaded from the SFTP account folder where you are currently "standing" as specified in the connection list object.

Usage

sftp_download(
  file,
  tofolder = getwd(),
  sftp_connection = get("sftp_con"),
  verbose = TRUE
)

Arguments

file

A character vector of file names. If the wildcard "*" is used, then all files on the SFTP url will be downloaded. NOTE! Folders (directories) will not be downloaded.

tofolder

A string containing a valid path - relative or absolute - to the folder where the files will be saved. Default is the working directory. If the folder does not exist it will be created.

sftp_connection

A list object created with sftp_connect. Default is 'sftp_con'.

verbose

Logical. Turn on messages to console. Default is TRUE.

Value

The function returns the number of files downloaded, following successful download.

Author(s)

Theodor Stenevang Klemming

See Also

sftp_upload, sftp_delete, sftp_rename

Other sftp: sftp_changedir(), sftp_connect(), sftp_delete(), sftp_listdirs(), sftp_listfiles(), sftp_list(), sftp_makedir(), sftp_removedir(), sftp_rename(), sftp_upload()

Examples


## Not run: 
# minimal - take all files on the SFTP url and save in the working directory
sftp_download("*")

# take a vector of file names from a dataframe
sftp_download(file = files$name, tofolder = "my/relative/path")

# take one specific file name from a vector from a dataframe
sftp_download(file = files$name[1], tofolder = getwd() )

## End(Not run)


jesse-smith/coviData documentation built on Jan. 14, 2023, 11:08 a.m.