Upload a file with POST() or PUT().

upload_file(path, type = NULL)

Arguments

path

path to file

type

mime type of path. If not supplied, will be guess by mime::guess_type() when needed.

Examples

citation <- upload_file(system.file("CITATION")) POST("http://httpbin.org/post", body = citation)
#> Response [http://httpbin.org/post] #> Date: 2019-08-23 16:09 #> Status: 200 #> Content-Type: application/json #> Size: 1.5 kB #> { #> "args": {}, #> "data": "bibentry(\"Manual\",\n title = \"R: A Language and Environ... #> "files": {}, #> "form": {}, #> "headers": { #> "Accept": "application/json, text/xml, application/xml, */*", #> "Accept-Encoding": "deflate, gzip", #> "Content-Length": "956", #> "Content-Type": "text/plain", #> ...
POST("http://httpbin.org/post", body = list(y = citation))
#> Response [http://httpbin.org/post] #> Date: 2019-08-23 16:09 #> Status: 200 #> Content-Type: application/json #> Size: 1.58 kB #> { #> "args": {}, #> "data": "", #> "files": { #> "y": "bibentry(\"Manual\",\n title = \"R: A Language and Environm... #> }, #> "form": {}, #> "headers": { #> "Accept": "application/json, text/xml, application/xml, */*", #> "Accept-Encoding": "deflate, gzip", #> ...