public void Submit(SubmissionManifest parameters) { WebRequest req = WebRequest.Create(parameters.ResolvedTransport); if (req is HttpWebRequest) { HttpWebRequest request = (HttpWebRequest)req; MultipartBuilder multipart = new MultipartBuilder(request); ITarget assignment = parameters.Assignment; foreach (string key in assignment.TransportParameters.Keys) { string value = assignment.TransportParameters[key]; string resolvedValue = parameters.ResolveParameter(value); if (key.StartsWith("$file.")) { string trueKey = key.Substring("$file.".Length); Stream stream = multipart.BeginWriteFile(trueKey, resolvedValue, "application/octet-stream"); parameters.PackageContentsIntoStream(stream); multipart.EndWriteFile(); } else { multipart.WriteParameter(key, resolvedValue); } } multipart.Close(); WebResponse response = request.GetResponse(); Stream respStream = response.GetResponseStream(); StringBuilder responseHolder = new StringBuilder(); StreamReader reader = new StreamReader(respStream, Encoding.UTF8); char[] buffer = new char[BufferSize]; int len; while ((len = reader.Read(buffer, 0, BufferSize)) > 0) { responseHolder.Append(buffer, 0, len); } response.Close(); this.response = responseHolder.ToString(); } }
// ------------------------------------------------------------------- public void Submit(SubmissionManifest manifest) { WebRequest req = WebRequest.Create(manifest.ResolvedTransport); if (req is FileWebRequest) { FileWebRequest request = (FileWebRequest)req; request.Method = WebRequestMethods.File.UploadFile; Stream stream = request.GetRequestStream(); manifest.PackageContentsIntoStream(stream); stream.Close(); } }
public void Submit(SubmissionManifest manifest) { WebRequest req = WebRequest.Create(manifest.ResolvedTransport); if (req is FtpWebRequest) { FtpWebRequest request = (FtpWebRequest)req; request.Method = WebRequestMethods.Ftp.UploadFile; request.UseBinary = true; Stream stream = request.GetRequestStream(); manifest.PackageContentsIntoStream(stream); stream.Close(); // Send the request by getting the response. request.GetResponse(); } }
public void Submit(SubmissionManifest manifest) { WebRequest req = WebRequest.Create(manifest.ResolvedTransport); if (req is FtpWebRequest) { FtpWebRequest request = (FtpWebRequest)req; request.Method = WebRequestMethods.Ftp.UploadFile; request.UseBinary = true; Stream stream = request.GetRequestStream(); manifest.PackageContentsIntoStream(stream); stream.Close(); // Send the request by getting the response. request.GetResponse(); } }
public void Submit(SubmissionManifest parameters) { WebRequest req = WebRequest.Create(parameters.ResolvedTransport); if (req is HttpWebRequest) { HttpWebRequest request = (HttpWebRequest)req; MultipartBuilder multipart = new MultipartBuilder(request); ITarget assignment = parameters.Assignment; foreach (string key in assignment.TransportParameters.Keys) { string value = assignment.TransportParameters[key]; string resolvedValue = parameters.ResolveParameter(value); if (key.StartsWith("$file.")) { string trueKey = key.Substring("$file.".Length); Stream stream = multipart.BeginWriteFile(trueKey, resolvedValue, "application/octet-stream"); parameters.PackageContentsIntoStream(stream); multipart.EndWriteFile(); } else { multipart.WriteParameter(key, resolvedValue); } } multipart.Close(); WebResponse response = request.GetResponse(); Stream respStream = response.GetResponseStream(); StringBuilder responseHolder = new StringBuilder(); StreamReader reader = new StreamReader(respStream, Encoding.UTF8); char[] buffer = new char[BufferSize]; int len; while ((len = reader.Read(buffer, 0, BufferSize)) > 0) { responseHolder.Append(buffer, 0, len); } response.Close(); this.response = responseHolder.ToString(); } }