private void AddImage(string path, string file, string contentType)
{
Utility.Utility.ThrowIfNull(file);
if (contentType == null)
{
contentType = "application/octet-stream";
}
FileInfo fi = new FileInfo(file);
HttpRequest request = CreateHttpRequest(new Uri(this.Smartsheet.BaseURI, path), HttpMethod.POST);
request.Headers["Content-Disposition"] = "attachment; filename=\"" + fi.Name + "\"";
HttpEntity entity = new HttpEntity();
entity.ContentType = contentType;
entity.Content = File.ReadAllBytes(file);
entity.ContentLength = fi.Length;
request.Entity = entity;
HttpResponse response = this.Smartsheet.HttpClient.Request(request);
switch (response.StatusCode)
{
case HttpStatusCode.OK:
break;
default:
HandleError(response);
break;
}
this.Smartsheet.HttpClient.ReleaseConnection();
}