[R] writing binary data from RCurl and postForm
Greg Donald
gdonald at gmail.com
Wed Aug 5 20:52:52 CEST 2015
I'm using RCurl with postForm() to post to a URL that responds with a
PDF. I cannot figure out how to write the resulting PDF data to a
file without corruption.
result = postForm(url, binary=TRUE)
Both this:
capture.output(result, file='/tmp/export.pdf')
and this:
f = file('/tmp/export.pdf', 'wb')
write(result, f)
close(f)
result in a corrupted PDF.
I also tried postForm without binary=TRUE but that halts execution
with an "embedded nul in string" error.
I also tried writeBin() but that complains about my result not being a vector.
I can use curl on the command line and this works fine, but I need to
get this working in R. Any help would be greatly appreciated.
Thanks.
--
Greg Donald
More information about the R-help
mailing list