View source: R/ftp_makeParams.R
ftp_makeParams | R Documentation |
Create url strings and, optionally, authentication parameters for FTP endpoint interactions
ftp_makeParams(host, protocol = "ftp", user = NULL, pwd = NULL, extras = NULL)
host |
(required) The host address string. Should take the form of |
protocol |
(optional) The protocol to use; defaults to |
user |
(optional) User login name, if host access requires authentication. If provided, pwd must also be a valid string |
pwd |
(optional) User password, if host access requires authentication. If provided, user must also be a valid string |
extras |
(optional) Additional arguments to pass to output. If provided, must be a named vector. |
This is a simple helper function that is most useful for constructing argument-lists to pass to e.g.
getURL
; the outputs are named with this use case in mind. See examples.
This function normalizes common variants of input formats for host and protocol. See examples.
If extras are not supplied, a named list of length 2, containing the url
and userpwd
.
If either user or pwd are missing OR are blank, the second element will be NULL
.
If extras are supplied, a named list of length 2 plus length(extras)
.
Other ftp_functions:
ftp_getBinPars()
,
ftp_listDir()
,
ftp_parseMeta()
# with authentication ftp_makeParams(host = "ftp.123.com", user = "myself", pwd = "my_pwd") # NULL or blank for either of user or pwd will result in NULL userpwd ftp_makeParams(host = "ftp.123.com", user = "myself", pwd = " ") # host and protocol input normalization x0 <- ftp_makeParams(host = "ftp.123.com", protocol = "ftp" ) x1 <- ftp_makeParams(host = "ftp://ftp.123.com", protocol = "ftp") x2 <- ftp_makeParams(host = "ftp://ftp.123.com", protocol = "ftp://") x3 <- ftp_makeParams(host = "ftp://ftp.123.com") all(sapply(list(x1, x2, x3), function(f) identical(x0, f))) # If you wanted to get a listing of all files: ## Not run: library(RCurl) my_params <- ftp_makeParams(host = "ftp.123.com", user = "myself", pwd = "my_pwd") my_params$ftplistonly <- TRUE do.call(getURL, my_params) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.