I spent another three hours digging into this problem, and I'm
relatively confident that this commit broke the upload function:
https://github.com/omegahat/RCurl/commit/b1f88c14e85893db10df8b264bc3ea2ec8085072#L8L120
It is unclear to me why .params was changed to lapply(.params, as,
"character") instead of as.list(.params), since the commit message
"writing chapter" was vague, but the consequence is that it breaks the
results from fileUpload(), e.g.
> library(RCurl)
> .params = list(file = fileUpload(file.path(R.home(), 'NEWS')))
> lapply(.params, as, "character")
$file
[1] "/usr/lib/R/NEWS" "character(0)" "character(0)"
> # it should really be this:
> .params
$file
$filename
[1] "/usr/lib/R/NEWS"
$contents
character(0)
$contentType
character(0)
attr(,"class")
[1] "FileUploadInfo"
It I revert that single change, postForm() will be able to upload
files again. However, even if I do that, there is still a problem
which I cannot figure out: the file seems to be uploaded twice. Here
is one of the results I got when I tried to upload an image to imgur
with knitr::imgur_upload():
> str(res)
atomic [1:1] <?xml version="1.0" encoding="utf-8"?>
<upload><image><name>~/tmp/sweave/figure/lmex.png</name><title/><caption/><hash>vaSmW</hash><deletehash>9PbLOHIIKPczb3h</deletehash><datetime>2012-10-24
02:29:25</datetime><type>image/png</type><animated>false</animated><width>504</width><height>504</height><size>5869</size><views>0</views><bandwidth>0</bandwidth></image><links><original>
http://i.imgur.com/vaSmW.png</original><imgur_page>
http://imgur.com/vaSmW</imgur_page><delete_page>
http://imgur.com/delete/9PbLOHIIKPczb3h</delete_page><small_square>
http://i.imgur.com/vaSmWs.jpg</small_square><large_thumbnail>
http://i.imgur.com/vaSmWl.jpg</large_thumbnail></links></upload>
HTTP/1.1 100 Continue
HTTP/1.1 200 Ok
Server: nginx
Date: Wed, 24 Oct 2012 02:29:26 GMT
Content-Type: application/xml
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: IMGURSESSION=ll6v92n7gl71pg0v9i8ffkfde3; path=/; domain=.
imgur.com
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Set-Cookie: _nc=1; path=/; domain=.
imgur.com; httponly
Access-Control-Allow-Origin: *
X-RateLimit-Limit: 500
X-RateLimit-Remaining: 410
X-RateLimit-Reset: 1351047952
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
<?xml version="1.0" encoding="utf-8"?>
<upload><image><name>~/tmp/sweave/figure/lmex.png</name><title/><caption/><hash>pMuuJ</hash><deletehash>O1QBH9SRJQ72oWO</deletehash><datetime>2012-10-24
02:29:26</datetime><type>image/png</type><animated>false</animated><width>504</width><height>504</height><size>5869</size><views>0</views><bandwidth>0</bandwidth></image><links><original>
http://i.imgur.com/pMuuJ.png</original><imgur_page>
http://imgur.com/pMuuJ</imgur_page><delete_page>
http://imgur.com/delete/O1QBH9SRJQ72oWO</delete_page><small_square>
http://i.imgur.com/pMuuJs.jpg</small_square><large_thumbnail>
http://i.imgur.com/pMuuJl.jpg</large_thumbnail></links></upload>
- attr(*, "Content-Type")= Named chr "application/xml"
..- attr(*, "names")= chr ""
----
The imguR package was apparently broken as well; its author gave up
postForm() and turned to Hadley's httr package for the POST() function
instead, which uses .postForm() instead of postForm()
I guess that is all I can do and explain at the moment; I really
cannot afford more time on this problem. I'll be grateful if Duncan
could offer some help.