Using RCurl to upload CEL files to a LIMS
2
0
Entering edit mode
@stephenmnemosynecouk-3983
Last seen 10.2 years ago
Dear Bioconductor mailing list, I am trying without success to upload an Affy CEL file to a LIMS system using RCurl. The LIMS expects to receive a multipart formatted http post request with some metadata in the headers. When I try to create an RCurl statement to upload the file I get various errors complaining that Http GET is not supported on the server - any help or suggestions would be very gratefully received. uri <- "http://127.0.0.1:8080/tomcat/ezUploader" f = CFILE("example.CEL") fileOid="12345" analyticalGroup="12345" curlPerform(url=uri, httpheader=c(fileOid=fileOid, analyticalGroup=analyticalGroup), upload=TRUE, readdata=f@ref, infilesize=file.info(filename)[1, "size"]) An attempt to upload the given CEL file leads to a tomcat error - Apache Tomcat/6.0.18 - Error report - HTTP Status 405 - HTTP method PUT is not supported by this URL. The Java code below using the Apache HttpClient demonstrates what I am trying to achieve HttpPost httpPost = new HttpPost(url.toString()); MultipartEntity entity = new MultipartEntity(); entity.addPart("fileOid", new StringBody("12345", Charset.forName("UTF-8"))); FileBody fileBody = new FileBody(filename); entity.addPart(filename.getName(), fileBody); httpPost.setEntity(entity); Any help with the RCurl equivalent would be very gratefully received Thanks Stephen sessionInfo() R version 2.10.1 (2009-12-14) i386-apple-darwin8.11.1 locale: [1] C/UTF-8/C/C/C/C attached base packages: [1] tools stats graphics grDevices utils datasets methods [8] base other attached packages: [1] mnemosynePicnic_0.1.1 XML_2.6-0 RCurl_1.3-1 [4] bitops_1.0-4.1 [[alternative HTML version deleted]]
affy affy • 1.7k views
ADD COMMENT
0
Entering edit mode
Geoff Jentry ▴ 50
@geoff-jentry-3956
Last seen 10.2 years ago
On Mon, 22 Mar 2010, stephen at mnemosyne.co.uk wrote: <snip> > HttpPost httpPost = new HttpPost(url.toString()); <snip> > Any help with the RCurl equivalent would be very gratefully received Have you played around with postForm?
ADD COMMENT
0
Entering edit mode
On Mon, Mar 22, 2010 at 4:48 PM, Geoff Jentry <geoffjentry at="" hexdump.org=""> wrote: > On Mon, 22 Mar 2010, stephen at mnemosyne.co.uk wrote: > <snip> >> >> HttpPost httpPost = new HttpPost(url.toString()); > > <snip> >> >> Any help with the RCurl equivalent would be very gratefully received > > Have you played around with postForm? and fileUpload()? Sean
ADD REPLY
0
Entering edit mode
Thanks - fileUpload looks pretty promising, though documentation appears a little vague. I'll have a crack with this - any pointers would be great! Cheers Stephen On Mar 22, 2010, at 10:51 PM, Sean Davis wrote: > On Mon, Mar 22, 2010 at 4:48 PM, Geoff Jentry <geoffjentry at="" hexdump.org=""> wrote: >> On Mon, 22 Mar 2010, stephen at mnemosyne.co.uk wrote: >> <snip> >>> >>> HttpPost httpPost = new HttpPost(url.toString()); >> >> <snip> >>> >>> Any help with the RCurl equivalent would be very gratefully received >> >> Have you played around with postForm? > > and fileUpload()? > > Sean
ADD REPLY
0
Entering edit mode
postForm and curlPerform both behave identically, and use just slight differences in structure - no luck with either! Thanks for the suggestion though. Cheers Stephen On Mar 22, 2010, at 10:48 PM, Geoff Jentry wrote: > On Mon, 22 Mar 2010, stephen at mnemosyne.co.uk wrote: > <snip> >> HttpPost httpPost = new HttpPost(url.toString()); > <snip> >> Any help with the RCurl equivalent would be very gratefully received > > Have you played around with postForm?
ADD REPLY
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 10.2 years ago
Hi Stephen, On 3/22/10 12:37 PM, stephen at mnemosyne.co.uk wrote: > I am trying without success to upload an Affy CEL file to a LIMS > system using RCurl. > The LIMS expects to receive a multipart formatted http post request > with some metadata in the headers. When I try to create an RCurl > statement to upload the file I get various errors complaining that > Http GET is not supported on the server - any help or suggestions > would be very gratefully received. If your server wants an HTTP POST request with Content-Type: multipart/form-data, then maybe I can help. Otherwise, I'm not sure I know what you want from your description. Using the curl command line, I think you want something like this: curl -F "fileOid=12345" \ -F "analyticalGroup=bob" \ -F "thefile=@thedata.txt" \ http://your-server/ I think you can achieve this using RCurl as follows: > library("RCurl") > uri <- "http://your-server/" > postForm(uri, > fileOid = "1234", > analyticalGroup = "bob", > theFile = fileUpload(filename = "~/temp/thedata.txt", > contentType = "text/amazing"), > .encoding="uft-8") If that does not work for you, perhaps you can try finding the right incantation using the curl command line. With that, there is probably a way to figure out how to get RCurl to do what you want. + seth -- Seth Falcon Bioconductor Core Team | FHCRC
ADD COMMENT
0
Entering edit mode
Dear Seth, Fantastic - this has the problem cracked! Cheers Stephen On Mar 27, 2010, at 1:55 AM, Seth Falcon wrote: > Hi Stephen, > > On 3/22/10 12:37 PM, stephen at mnemosyne.co.uk wrote: >> I am trying without success to upload an Affy CEL file to a LIMS >> system using RCurl. > >> The LIMS expects to receive a multipart formatted http post request >> with some metadata in the headers. When I try to create an RCurl >> statement to upload the file I get various errors complaining that >> Http GET is not supported on the server - any help or suggestions >> would be very gratefully received. > > If your server wants an HTTP POST request with Content-Type: multipart/form-data, then maybe I can help. Otherwise, I'm not sure I know what you want from your description. > > Using the curl command line, I think you want something like this: > > curl -F "fileOid=12345" \ > -F "analyticalGroup=bob" \ > -F "thefile=@thedata.txt" \ > http://your-server/ > > I think you can achieve this using RCurl as follows: > >> library("RCurl") >> uri <- "http://your-server/" >> postForm(uri, >> fileOid = "1234", >> analyticalGroup = "bob", >> theFile = fileUpload(filename = "~/temp/thedata.txt", >> contentType = "text/amazing"), >> .encoding="uft-8") > > If that does not work for you, perhaps you can try finding the right incantation using the curl command line. With that, there is probably a way to figure out how to get RCurl to do what you want. > > + seth > > > -- > Seth Falcon > Bioconductor Core Team | FHCRC
ADD REPLY

Login before adding your answer.

Traffic: 754 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6