Smartsheet.Api.Internal.RowColumnResourcesImpl.AddImage C# (CSharp) Method

AddImage() private method

Attach file.
the file not found exception the Smartsheet exception
private AddImage ( string path, string file, string contentType ) : void
path string the url path
file string the file
contentType string the content Type
return void
        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();
        }