ftp_fetch: Fetch files from an FTP server

Description Usage Arguments Details Value Examples

View source: R/ftp_fetch.R

Description

Fetch files from an FTP server

Usage

1
ftp_fetch(url, disk = NULL, stream = NULL, messages = FALSE, ...)

Arguments

url

(character) URL for the file on the FTP server

disk

(character) a path to write to. if NULL (default), memory used. See curl::curl_fetch_disk() for help.

stream

(character) an R function to determine how to stream data. if NULL (default), memory used. See curl::curl_fetch_stream() for help.

messages

(logical) verbose messages. Default: FALSE

...

further args passed on to curl

Details

Only one of disk or stream parameters can be passed

Value

string, path to the file on disk

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
url <- "ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/by_year/1882.csv.gz"

# disk
file <- tempfile(fileext = ".csv.gz")
ftp_fetch(url, disk = file)
utils::read.delim(file, sep = ",", nrows = 10, header = FALSE)
unlink(file) # cleanup

# stream - NOT WORKING QUITE YET
lst <- c()
fun <- function(x) lst <<- c(lst, x)
ftp_fetch(url, stream = fun)
lst

## End(Not run)

ropensci/ftp documentation built on Sept. 3, 2020, 3:34 a.m.