Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

write_disk

Control where the response body is written.


Description

The default behaviour is to use write_memory(), which caches the response locally in memory. This is useful when talking to APIs as it avoids a round-trip to disk. If you want to save a file that's bigger than memory, use write_disk() to save it to a known path.

Usage

write_disk(path, overwrite = FALSE)

write_memory()

Arguments

path

Path to content to.

overwrite

Will only overwrite existing path if TRUE.

Examples

tmp <- tempfile()
r1 <- GET("https://www.google.com", write_disk(tmp))
readLines(tmp)

# The default
r2 <- GET("https://www.google.com", write_memory())

# Save a very large file
## Not run: 
GET(
  "http://www2.census.gov/acs2011_5yr/pums/csv_pus.zip",
  write_disk("csv_pus.zip"), progress()
)

## End(Not run)

httr

Tools for Working with URLs and HTTP

v1.4.2
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.