0

I have a Java web application running.

Now, I have this R sample script:

zz <- file(outputTarget, "w")  
cat("TITLE extra line", "2 3 5 7", "", "11 13 17", file = zz, sep = "\n")
cat("One more line\n", file = zz)
close(zz)

When "outputTarget" = D://R-Stuff//dataOut.txt the file is created fine.

Now, I need to send this file to my web server.

The only thing that comes to my mind is to change "outputTarget" to http://myhost:8080/myapplication/mystrutsaction/dataOut.txt but I'm sure this will not work because Struts cannot handle this.

What I need to do (in generic way, how can I handle a file saved to URL in Java Web application)?

Altaf Hussain
  • 5,166
  • 4
  • 30
  • 47
Magno C
  • 1,922
  • 4
  • 28
  • 53
  • I need the server side stuff. To handle things like `file = new File("http://myhost:8080/myapplication/mystrutsaction/dataOut.txt"); fop = new FileOutputStream(file);` – Magno C Nov 12 '14 at 12:33

1 Answers1

1

If I get you right you are trying to send a file from R to a web service. So R has to generate a POST request. May be POST request using RCurl is the answer

Community
  • 1
  • 1
Oncaphillis
  • 1,888
  • 13
  • 15
  • You get it right. I'll take a look and post the results soon. – Magno C Nov 12 '14 at 13:07
  • The best answer seemed to relate to the [httr library](http://cran.r-project.org/web/packages/httr/index.html) – Oncaphillis Nov 12 '14 at 13:16
  • Yes. This is just what I need. Unfortunately my windows environment does not allow me to test this right now since httr not came by default and I have no curl installed, but I can see it will work. – Magno C Nov 12 '14 at 13:35