check_curl: Check for contents on server via cURL

View source: R/transfer.R

check_curlR Documentation

Check for contents on server via cURL

Description

check_curl will connect to a server, typically a (secure) file transfer protocol available with cURL and check for the presence of a file with the provided pattern, if any.

Usage

check_curl(
  connection = NULL,
  handle_options = list(),
  pattern = NULL,
  detailed_output = FALSE
)

Arguments

connection

Character string that is used to connect to the desired file system (ensure ends with a /).

handle_options

List of names elements for the cURL handle (for sftp connections, typically username and password are provided).

pattern

Character string, typically a file name or portion thereof, that will be used in the search. Default is today's date.

detailed_output

Logical value to return the entire file list at remote location; default is FALSE.

Details

This function is used in conjunction with the transfer_curl function and can detect if the file of interest is actually available for download. check_curl is a thin wrapper around curl functionality; more specifically, the core process uses curl_fetch_memory. cURL requires a 'handle' to be specified, which as the name suggests, specifies how cURL will 'handle' the server request. Details such as username, password, verbose can be specified in the handle. See the examples for some common patterns.

Value

A logical value of whether or not the pattern was found. If detailed_output, the entire list of files in target folder.

Examples

## Not run: 
# Test to see if the pattern is present in the server.
check_curl(pattern = 'June_22_2020', connection = 'YOUR(S)FTPURL', detailed_output = TRUE)
check_curl(connection = 'YOUR(S)FTPURLPATH',
           handle_options = list(username = 'myuid', password = 'mypwd', verbose = TRUE),
           detailed_output = TRUE)

## End(Not run)

al-obrien/farrago documentation built on April 14, 2023, 6:20 p.m.