Rook (version 1.1-1)

Multipart-class: Class Multipart and object Multipart

Description

A convenience object for parsing multipart/form-data POST payloads.

Arguments

Methods

parse(env):

Returns parsed POST payload as a named list. env is an environment created by Rhttpd and conforms to the Rook specification.

See Also

Rhttpd, Request, and Response.

Examples

Run this code
s <- Rhttpd$new()
if (FALSE) {
s$start(quiet=TRUE)
}
s$add(name="multi",
    app=function(env){
        req <- Request$new(env)
        res <- Response$new()
        res$write('')
        res$write('Upload a file: ')
        res$write('')
        post <- Multipart$parse(env)
        if (length(post)){
            poststr <- paste(capture.output(str(post),file=NULL),collapse='\n')
            res$write(c('',poststr,''))
        }
        res$finish()
    }
)
if (FALSE) {
s$browse('multi') # Opens a browser window to the app.
}
s$remove(all=TRUE)
rm(s)

Run the code above in your browser using DataCamp Workspace