public MultipartFormDataParser ( |
||
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 | /// 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 |
public MultipartFormDataParser(Stream stream, string boundary, Encoding encoding, int binaryBufferSize)
{
Files = new List<FilePart>();
Parameters = new List<ParameterPart>();
var streamingParser = new StreamingMultipartFormDataParser(stream, boundary, encoding, binaryBufferSize);
streamingParser.ParameterHandler += parameterPart => Parameters.Add(parameterPart);
streamingParser.FileHandler += (name, fileName, type, disposition, buffer, bytes) =>
{
if (Files.Count == 0 || name != Files[Files.Count - 1].Name)
{
Files.Add(new FilePart(name, fileName, new MemoryStream(), type, disposition));
}
Files[Files.Count - 1].Data.Write(buffer, 0, bytes);
};
streamingParser.Run();
// Reset all the written memory streams so they can be read.
foreach (var file in Files)
{
file.Data.Position = 0;
}
}
MultipartFormDataParser::MultipartFormDataParser ( |
|
MultipartFormDataParser::MultipartFormDataParser ( |
|
MultipartFormDataParser::MultipartFormDataParser ( |
|
MultipartFormDataParser::MultipartFormDataParser ( |
|
MultipartFormDataParser::MultipartFormDataParser ( |