Reputation: 918
I am trying to encode a list as JSON, compress it using gzip in Rcompression, and send it to a server using a POST request in RCurl.
# COMPRESS THE REQUEST
all <- list(this=1,is=2,a=3,list=4)
json <- toJSON(all)
gzip <- gzip(json)
# SEND IT TO THE SERVER
status <- postForm(SERVER_URI,data=fileUpload(contents=gzip,contentType="application/x-gzip"),style="HTTPPOST",binary=TRUE)
However, when I try to POST the data to the server, I get the following error:
Error in postForm(SERVER_URI, data = gzip) :
STRING_ELT() can only be applied to a 'character vector', not a 'raw'
I understand that the gzip data is in raw format and the postForm function does not like that, but I'm unclear how to resolve the issue to send the raw data to the server via a POST request.
Upvotes: 2
Views: 389
Reputation: 843
The official paper for RCurl states that POSTing binary data has not yet been implemented, and is listed in the document under "Future Work". So, maybe there's no solution for this yet in RCurl since the document was published.
Upvotes: 1