private static async Task<string> UploadTextFileToServer(Uri server, string login, string password,
string stream, int objectType, int sessionId, int projectId, int batchId, int parentId,
int objectId, int version, string streamName)
{
var creds = CredentialCache.DefaultNetworkCredentials;
if (!string.IsNullOrEmpty(login)) creds = new NetworkCredential(login, password);
using (var handler = new HttpClientHandler { Credentials = creds })
using (var client = new HttpClient(handler))
{
var encodedStreamName = Convert.ToBase64String(Encoding.Unicode.GetBytes(streamName));
var content = new MultipartFormDataContent
{
{new StringContent("Save"), "Action"},
{new StringContent(objectType.ToString()), "objectType"},
{new StringContent(sessionId.ToString()), "sessionId"},
{new StringContent(projectId.ToString()), "projectId"},
{new StringContent(batchId.ToString()), "batchId"},
{new StringContent(parentId.ToString()), "parentId"},
{new StringContent(objectId.ToString()), "objectId"},
{new StringContent(version.ToString()), "version"},
{new StringContent(encodedStreamName), "streamName"},
{new ByteArrayContent(Encoding.Unicode.GetBytes(stream)), "blob", "data.txt"}
};
var msg = client.PostAsync(server, content).Result;
return await msg.Content.ReadAsStringAsync();
}
}