예제 #1
0
        public override void ToStream(Stream stream, Encoding encoding, string boundary)
        {
            string contentType = "application/octet-stream";

            if (FileName.EndsWith("txt"))
            {
                contentType = "text/plain";
            }
            else if (FileName.EndsWith("smil"))
            {
                contentType = "text/xml";
            }
            else if (FileName.EndsWith("jpg"))
            {
                contentType = "image/jpeg";
            }
            else if (FileName.EndsWith("png"))
            {
                contentType = "image/png";
            }
            string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type:{3}\r\n\r\n",
                                          boundary, this.Name, this.FileName, contentType);

            HttpClient.Logger.Info(header);
            HttpPart.StringToStream(stream, encoding, header);
            stream.Write(this.Data, 0, this.Data.Length);
            //HttpPart.StringToStream(stream, encoding, "\r\n");
        }
예제 #2
0
        public override void ToStream(Stream stream, Encoding encoding, string boundary)
        {
            string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}",
                                          boundary, this.Name, this.Data);

            HttpClient.Logger.Info(header);
            HttpPart.StringToStream(stream, encoding, header);
        }
예제 #3
0
        public void ToStream(Stream stream, Encoding encoding)
        {
            foreach (HttpPart part in this.List)
            {
                part.ToStream(stream, encoding, Boundary);
                HttpPart.StringToStream(stream, encoding, "\r\n");
            }
            HttpPart.StringToStream(stream, encoding, EndBoundary);

            stream.Flush();
        }
예제 #4
0
 public void RemovePart(HttpPart part)
 {
     List.Remove(part);
 }
예제 #5
0
 public void AddPart(HttpPart part)
 {
     List.Add(part);
 }