Module mochiweb_multipart

Utilities for parsing multipart/form-data.

Copyright © 2007 Mochi Media, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors: Bob Ippolito (bob@mochimedia.com).

Description

Utilities for parsing multipart/form-data.

Data Types

bodypart()

bodypart() = {Start::integer(), End::integer(), Body::iolist()}

file_handler()

file_handler() = fun((Filename::string(), ContentType::string()) -> file_handler_callback())

file_handler_callback()

file_handler_callback() = fun((binary() | eof) -> file_handler_callback()) | term()

formfile()

formfile() = {Name::string(), ContentType::string(), Content::binary()}

header()

header() = {key(), value()}

key()

key() = atom() | string() | binary()

request()

abstract datatype: request()

value()

value() = atom() | iolist() | integer()

Function Index

default_file_handler/2
parse_form/1Parse a multipart form from the given request using the in-memory default_file_handler/2.
parse_form/2Parse a multipart form from the given request using the given file_handler().
parse_multipart_request/2
parts_to_body/3Return {[header()], iolist()} representing the body for the given parts, may be a single part or multipart.
parts_to_multipart_body/4Return {[header()], iolist()} representing the body for the given parts, always a multipart response.

Function Details

default_file_handler/2

default_file_handler(Filename, ContentType) -> any()

parse_form/1

parse_form(Req::request()) -> [{string(), string() | formfile()}]

Parse a multipart form from the given request using the in-memory default_file_handler/2.

parse_form/2

parse_form(Req::request(), F::file_handler()) -> [{string(), string() | term()}]

Parse a multipart form from the given request using the given file_handler().

parse_multipart_request/2

parse_multipart_request(Req, Callback) -> any()

parts_to_body/3

parts_to_body(BodyList::[bodypart()], ContentType::string(), Size::integer()) -> {[header()], iolist()}

Return {[header()], iolist()} representing the body for the given parts, may be a single part or multipart.

parts_to_multipart_body/4

parts_to_multipart_body(BodyList::[bodypart()], ContentType::string(), Size::integer(), Boundary::string()) -> {[header()], iolist()}

Return {[header()], iolist()} representing the body for the given parts, always a multipart response.


Generated by EDoc