Jeroen Ooms
unread,Mar 10, 2013, 6:05:08 PM3/10/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rr...@googlegroups.com
In RApache, request data for a multipart/form-data HTTP POST will be
available in the session in two files:
POST : contains posted form variables
FILES: contains posted files
I am trying to accomplish the same in Rook. However, both the output
of req$POST() and Multipart$parse(env) contain a mix of the files and
arguments.
Questions:
- Is there a native way to get just the FILES, and just the arguments
from a http post request, as in rapache? Or do I need to extract these
from the POST() output?
- Are Multipart$parse(env) and req$POST supposed to return the same output?
Below a modified example from the manual
library(Rook)
s <- Rhttpd$new()
s$start(quiet=TRUE)
s$add(
name="multi",
app=function(env){
req <- Request$new(env)
res <- Response$new()
res$write('<form enctype="multipart/form-data" method=POST>')
res$write('Upload a file: <input type=file name=fileUpload> <br />')
res$write('Some variables: <input type="text" name="somevar"> <br />')
res$write('<input type=submit></form><br>')
post <- Multipart$parse(env)
if (length(post)){
poststr <- paste(capture.output(str(post),file=NULL),collapse='\n')
res$write(c('<pre>',poststr,'</pre>'))
}
HTTPPOST <- req$POST();
if (length(HTTPPOST)){
newstr <- paste(capture.output(str(HTTPPOST),file=NULL),collapse='\n')
res$write(c('<pre>',newstr,'</pre>'))
}
res$finish()
}
)
s$browse('multi')