Skip to content

Downloads an object and parses it according to its extension (or format):

Usage

read_s3(key, bucket = NULL, ..., format = NULL, config = s3_config())

Arguments

key

Object key inside bucket, or an s3://bucket/key URL.

bucket

Bucket; defaults to the config's bucket (S3PE_BUCKET).

...

Passed to the reader (for example col_types for CSV, simplifyVector for JSON).

format

One of "csv", "tsv", "json", "geojson", "parquet", "rds", "xlsx", "text", "raw"; overrides the extension.

config

An s3_config().

Value

The parsed object, as in the table.

Details

ExtensionReaderResult
.csv, .csv.gzreadr::read_csv()tibble
.tsv, .tsv.gzreadr::read_tsv()tibble
.jsonjsonlite::fromJSON()list or data frame
.geojsonsf::st_read() if sf is installed, else jsonlitesf or list
.parquetnanoparquet::read_parquet()data frame
.rdsreadRDS()the saved object
.xlsxreadxl::read_excel()tibble
.txt, .md, .html, .xml, .svg, ...character (one string)
anything elseraw vector

The byte count is checked against the server's Content-Length and, when the ETag is an MD5, against the MD5 of what arrived.

Examples

if (FALSE) { # interactive()
meta <- read_s3("data/manifest.json", bucket = "my-bucket")
meta$ultimo_mes

sales <- read_s3("s3://my-bucket/series/sales.csv.gz")

# the bytes, whatever the extension
png <- read_s3("report/figure1.png", bucket = "my-bucket", format = "raw")
}