download_file: Download a file to a temporary location

View source: R/filepaths.R

download_fileR Documentation

Download a file to a temporary location

Description

Excel documents cannot be loaded from a URL and need to be downloaded to a temporary file. This is a reusable and generalisable wrapper to do just that.

Usage

download_file(url, fileext = file_ext(url), dir = tempdir(), name = NULL)

Arguments

url

(character) the URL to the destination file

fileext

(character; default = file_ext(url)) the file extension of the file to download.

dir

(character; default = tempdir()) the folder into which to download the file. Use dot notation to download into the working directory.

name

(character; default = NULL) specify a name if you feel like it

Value

a file path string to the downloaded file

Examples

## Not run: 
download_file(
  url = "https://github.com/baslat/aus_geos_data/blob/master/geos.csv?raw=true",
  fileext = "csv",
  dir = "./outputs",
  name = "geos.csv"
)

## End(Not run)


baslat/sak documentation built on April 14, 2025, 4:14 p.m.