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 guess_type when needed.

Examples

citation <- upload_file(system.file("CITATION")) POST("http://httpbin.org/post", body = citation)
#> Response [http://httpbin.org/post] #> Date: 2017-08-16 14:13 #> Status: 200 #> Content-Type: application/json #> Size: 1.51 kB #> { #> "args": {}, #> "data": "bibentry(\"Manual\",\n title = \"R: A Language and Environ... #> "files": {}, #> "form": {}, #> "headers": { #> "Accept": "application/json, text/xml, application/xml, */*", #> "Accept-Encoding": "gzip, deflate", #> "Connection": "close", #> "Content-Length": "956", #> ...
POST("http://httpbin.org/post", body = list(y = citation))
#> Response [http://httpbin.org/post] #> Date: 2017-08-16 14:13 #> Status: 200 #> Content-Type: application/json #> Size: 1.59 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": "gzip, deflate", #> ...