Next: filesystem, Previous: parse-request, Up: Top
The (www server-utils form-2-form)
module provides a procedure to
parse a string in ‘multipart/form-data’ format.
Parse raw-data as raw form response data of enctype ‘multipart/form-data’ and return an alist.
content-type-more is a string that should include the
boundary="..."
information. (This parameter name reflects the typical source of such a string, the Content-Type header value, after the ‘multipart/form-data’.)Each element of the alist has the form
(
name.
value)
, where name is a string and value is either a string or four values (extractable bycall-with-values
):
- filename
- A string, or
#f
.- type
- A string representing the MIME type of the uploaded file.
- raw-headers
- A string, including all eol crlf chars. Incidentally, the type should be (redundantly) visible in one of the headers.
- squeeze
- A procedure that takes one arg abr (standing for access byte range). If abr is
#f
, then internal references to the uploaded file's data are dropped. Otherwise, abr should be a procedure that takes three arguments: a string, a beginning index (integer, inclusive), and an ending index (integer, exclusive).If there is no type information, value is a simple non-empty string, and no associated information (filename, raw-headers, squeeze) is kept.
parse-form
ignores degenerate uploads, that is those parts ofraw-data
where the part header specifies no filename and the part content-length is zero or unspecified.
squeeze
?The squeeze interface can help reduce data motion. Consider a common upload scenario: client uploads file(s) for local (server-side) storage.
classic squeeze * * 0. (current-input-port) * * 1. Guile-WWW string (for parsing purposes) * 2. your substring (image/jpeg) * * 3. filesystem
You can achieve the same effect as the “classic” approach by specifying
substring
(or something like it) as the access-byte-range proc, but
you don't have to. You could, instead, call squeeze with a
procedure that writes the byte range directly to the filesystem.