High Level
The best way I am aware of to get this done (in R) is to wrap a call to a system function. I personally use lftp, which has good handling for:
- FTPS
- Multiple files in/out
- Regex and wildcard file naming
This does have the downside of being hardware specific; it's not all nicely contained in R. That said, it can potentially save you a lot of time by leveraging tools which are good at what they do.
Sample Wrapper
A wrapper for LFTP could look like the function below -- this is a variant of what I use in production; I stripped out the logging functions which depend on a broader package. At the core, this is what moves files for me.
#' lftp wrapper to get/put file(s) from ftp-like sites
#'
#' @param process list, pipeable etl objects
#' @param configuration vector (text), list of
#' arguments to supply after call to lftp
#' @param skip boolean, whether to skip this step (testing)
#'
#' @details wrapper around lftp command line tool
#'
#' @export
#'
ftp <- function(configuration, skip = FALSE) {
if (!skip) {
system2("lftp",
args = configuration)
}
}
Configuration
The biggest part of the wrapper is the configuration vector. The configuration vector lets you pass an arbitrary set of parameters to lftp, including the ones you'll need to get the job done.
A sample configuration vector could look like:
c(
'your.ftp-server.com',
paste("-e", '"put '/path/to/file.csv' -o '/destination/'; exit;"'
)
Noting that you need to be careful about quoting (or you can incorporate shQuote(), but that's a different project).
Putting It Together
To answer your specific question, you could use this in R to:
- Get the data you're using from Quick Base using
rCurl
- Write it to a file somewhere on your hardware
- Use ftp() to leverage
lftp to send the file to its destination