C# Class HttpMultipartParser.MultipartFormDataParser

Provides methods to parse a multipart/form-data stream into it's parameters and file data.

A parameter is defined as any non-file data passed in the multipart stream. For example any form fields would be considered a parameter.

The parser determines if a section is a file or not based on the presence or absence of the filename argument for the Content-Type header. If filename is set then the section is assumed to be a file, otherwise it is assumed to be parameter data.

Mostra file Open project: Vodurden/Http-Multipart-Data-Parser Class Usage Examples

Public Methods

Method Description
GetParameterValue ( string name ) : string

Returns the value of a parameter or null if it doesn't exist. You should only use this method if you're sure the parameter has only one value. If you need to support multiple values use GetParameterValues.

GetParameterValues ( string name ) : IEnumerable

Returns the values of a parameter or an empty enumerable if the parameter doesn't exist.

HasParameter ( string name ) : bool

Returns true if the parameter has any values. False otherwise

MultipartFormDataParser ( Stream stream ) : System.Collections.Generic

Initializes a new instance of the MultipartFormDataParser class with an input stream. Boundary will be automatically detected based on the first line of input.

MultipartFormDataParser ( Stream stream, Encoding encoding ) : System.Collections.Generic

Initializes a new instance of the MultipartFormDataParser class with the input stream and stream encoding. Boundary is automatically detected.

MultipartFormDataParser ( Stream stream, Encoding encoding, int binaryBufferSize ) : System.Collections.Generic

Initializes a new instance of the MultipartFormDataParser class with the stream, input encoding and buffer size. Boundary is automatically detected.

MultipartFormDataParser ( Stream stream, string boundary ) : System.Collections.Generic

Initializes a new instance of the MultipartFormDataParser class with the boundary and input stream.

MultipartFormDataParser ( Stream stream, string boundary, Encoding encoding ) : System.Collections.Generic

Initializes a new instance of the MultipartFormDataParser class with the boundary, input stream and stream encoding.

MultipartFormDataParser ( Stream stream, string boundary, Encoding encoding, int binaryBufferSize ) : System.Collections.Generic

Initializes a new instance of the MultipartFormDataParser class with the boundary, stream, input encoding and buffer size.

Method Details

GetParameterValue() public method

Returns the value of a parameter or null if it doesn't exist. You should only use this method if you're sure the parameter has only one value. If you need to support multiple values use GetParameterValues.
public GetParameterValue ( string name ) : string
name string The name of the parameter
return string

GetParameterValues() public method

Returns the values of a parameter or an empty enumerable if the parameter doesn't exist.
public GetParameterValues ( string name ) : IEnumerable
name string The name of the parameter
return IEnumerable

HasParameter() public method

Returns true if the parameter has any values. False otherwise
public HasParameter ( string name ) : bool
name string The name of the parameter
return bool

MultipartFormDataParser() public method

Initializes a new instance of the MultipartFormDataParser class with an input stream. Boundary will be automatically detected based on the first line of input.
public MultipartFormDataParser ( Stream stream ) : System.Collections.Generic
stream System.IO.Stream /// The stream containing the multipart data ///
return System.Collections.Generic

MultipartFormDataParser() public method

Initializes a new instance of the MultipartFormDataParser class with the input stream and stream encoding. Boundary is automatically detected.
public MultipartFormDataParser ( Stream stream, Encoding encoding ) : System.Collections.Generic
stream System.IO.Stream /// The stream containing the multipart data ///
encoding System.Text.Encoding /// The encoding of the multipart data ///
return System.Collections.Generic

MultipartFormDataParser() public method

Initializes a new instance of the MultipartFormDataParser class with the stream, input encoding and buffer size. Boundary is automatically detected.
public MultipartFormDataParser ( Stream stream, Encoding encoding, int binaryBufferSize ) : System.Collections.Generic
stream System.IO.Stream /// The stream containing the multipart data ///
encoding System.Text.Encoding /// The encoding of the multipart data ///
binaryBufferSize int /// The size of the buffer to use for parsing the multipart form data. This must be larger /// then (size of boundary + 4 + # bytes in newline). ///
return System.Collections.Generic

MultipartFormDataParser() public method

Initializes a new instance of the MultipartFormDataParser class with the boundary and input stream.
public MultipartFormDataParser ( Stream stream, string boundary ) : System.Collections.Generic
stream System.IO.Stream /// The stream containing the multipart data ///
boundary string /// The multipart/form-data boundary. This should be the value /// returned by the request header. ///
return System.Collections.Generic

MultipartFormDataParser() public method

Initializes a new instance of the MultipartFormDataParser class with the boundary, input stream and stream encoding.
public MultipartFormDataParser ( Stream stream, string boundary, Encoding encoding ) : System.Collections.Generic
stream System.IO.Stream /// The stream containing the multipart data ///
boundary string /// The multipart/form-data boundary. This should be the value /// returned by the request header. ///
encoding System.Text.Encoding /// The encoding of the multipart data ///
return System.Collections.Generic

MultipartFormDataParser() public method

Initializes a new instance of the MultipartFormDataParser class with the boundary, stream, input encoding and buffer size.
public MultipartFormDataParser ( Stream stream, string boundary, Encoding encoding, int binaryBufferSize ) : System.Collections.Generic
stream System.IO.Stream /// The stream containing the multipart data ///
boundary string /// The multipart/form-data boundary. This should be the value /// returned by the request header. ///
encoding System.Text.Encoding /// The encoding of the multipart data ///
binaryBufferSize int /// The size of the buffer to use for parsing the multipart form data. This must be larger /// then (size of boundary + 4 + # bytes in newline). ///
return System.Collections.Generic