fetchFile: USGS Lidar Toolkit - Retrieve a file

View source: R/CoreFunctions.R

fetchFileR Documentation

USGS Lidar Toolkit – Retrieve a file

Description

This is a helper function used in the USGSlidar package to call utils::download.file() to retrieve individual index files and data tiles.

Usage

fetchFile(url, destfile, method = "libcurl", mode = "wb", ...)

Arguments

url

A character string with the URL for the file. If using local files, the URL should start with file:// and you should set method="auto".

destfile

A character string specifying the file name for the downloaded file.

method

Method used with download.file(). Refer to download.file() documentation for possible methods.

mode

A character string indicating the mode with which to write the file. Refer to download.file() documentation for possible modes.

...

Additional arguments passed to download.file().

Details

When retrieving large files, it may be necessary to increase the timeout period so downloads can complete. This is done using the following line of code (sets timeout to 5000 seconds):

options(timeout = max(5000, getOption("timeout")))

Value

An (invisible) integer code, 0 for success and non-zero for failure. This is the value returned from download.file.

Examples

## Not run: 
fetchFile("sample", "ftp://somewebsite.com/files/samplefile.bin")

## End(Not run)

bmcgaughey1/USGSlidar documentation built on June 23, 2024, 1:25 a.m.