HttpMultipartParser.MultipartFormDataParser.MultipartFormDataParser C# (CSharp) Method

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
        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;
            }
        }

Same methods

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