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"); }
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); }
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(); }
public void RemovePart(HttpPart part) { List.Remove(part); }
public void AddPart(HttpPart part) { List.Add(part); }