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: 2018-12-17 20:45 #> 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: 2018-12-17 20:45 #> 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", #> ...