This function copies a remote file to a local cache once and makes sure it is reused.
Usage
.cache_post(
url,
body,
as = c("text", "raw", "parsed", "httr"),
...,
.nocache = getOption("cache.disable", default = FALSE),
.cache = rappdirs::user_cache_dir(utils::packageName()),
.stale = Inf
)
Arguments
- url
the url to download
- body
a named list of POST data
- as
how the response is delivered?
- ...
Named arguments passed on to
httr::POST
config
Additional configuration settings such as http authentication (
authenticate()
), additional headers (add_headers()
), cookies (set_cookies()
) etc. Seeconfig()
for full details and list of helpers....
Further named parameters, such as
query
,path
, etc, passed on tomodify_url()
. Unnamed parameters will be combined withconfig()
.encode
If the body is a named list, how should it be encoded? Can be one of form (application/x-www-form-urlencoded), multipart, (multipart/form-data), or json (application/json).
For "multipart", list elements can be strings or objects created by
upload_file()
. For "form", elements are coerced to strings and escaped, useI()
to prevent double-escaping. For "json", parameters are automatically "unboxed" (i.e. length 1 vectors are converted to scalars). To preserve a length 1 vector as a vector, wrap inI()
. For "raw", either a character or raw vector. You'll need to make sure to set thecontent_type()
yourself.handle
The handle to use with this request. If not supplied, will be retrieved and reused from the
handle_pool()
based on the scheme, hostname and port of the url. By default httr requests to the same scheme/host/port combo. This substantially reduces connection time, and ensures that cookies are maintained over multiple requests to the same host. Seehandle_pool()
for more details.
- .nocache
if set to TRUE all caching is disabled
- .cache
the location of the downloaded files
- .stale
how long to leave this file before replacing it.