s3_get: download s3 file

View source: R/s3_get.R

s3_getR Documentation

download s3 file

Description

Files are downloaded to the R user data directory (i.e., tools::R_user_dir("s3", "data")) so they can be cached across all of an R user's sessions and projects. Specify an alternative download location by setting the R_USER_DATA_DIR environment variable (see ?tools::R_user_dir) or by using the data_dir argument.

Usage

s3_get(
  s3_uri,
  region = "us-east-2",
  quiet = FALSE,
  progress = FALSE,
  force = FALSE,
  public = FALSE,
  data_dir = tools::R_user_dir("s3", "data")
)

Arguments

s3_uri

URI for an S3 object

region

AWS region for bucket containing the file (defaults to "us-east-2", but only required for private files)

quiet

suppress messages?

progress

show download progress? (currently only for public objects)

force

force download to overwrite existing S3 object

public

defaults to FALSE; if TRUE, ignore any environment variables specifying AWS credentials and attempt to download the file as publicly available

data_dir

root directory for downloaded files (defaults to tools::R_user_dir("s3", "data"))

Value

a character string that is the file path to the downloaded file (invisibly)

Examples


Sys.setenv("R_USER_DATA_DIR" = tempdir())
the_file <- s3_get(s3_uri = "s3://geomarker/testing_downloads/mtcars.rds")
s3_get("s3://geomarker/testing_downloads/mtcars.rds") |>
    readRDS()
unlink(the_file)


s3 documentation built on Sept. 11, 2024, 7:03 p.m.