04-20-2009 03:51 PM
/// <summary>
/// Commits the changes to the document's data back to the server.
/// </summary>
public void Commit()
{
if(_contentChanged)
{
XDeclaration dec = new XDeclaration("1.0", "utf-8", "no");
XNamespace atom = "http://www.w3.org/2005/Atom";
XElement ele =
new XElement(atom + "entry",
new XElement(atom + "title", Title),
new XElement(atom + "content", Convert.ToBase64String(_data),
new XAttribute("type", MimeType),
new XAttribute("encoding", "base64")
)
);
byte[] data = System.Text.Encoding.UTF8.GetBytes(dec.ToString() + ele.ToString());
_repo.Server.PutRequest(_editMedia, data, "application/atom+xml;type=entry", new WebHeaderCollection());
}
}
and the PutRequest method:
/// <summary>
/// Executes an HTTP POST against a URI.
/// </summary>
/// <param name="uri">The URI to send the POST to.</param>
/// <param name="data">The data to include in the POST</param>
/// <param name="contentType">The MIME content type of the post.</param>
/// <param name="headers">The PUT headers for this request.</param>
/// <returns>The response stream.</returns>
internal Stream PutRequest(Uri uri, byte[] data, string contentType, WebHeaderCollection headers)
{
try
{
WebRequest request = WebRequest.Create(uri);
request.Headers = headers;
request.Method = "PUT";
request.Credentials = _credentials;
request.ContentType = contentType;
using(Stream str = request.GetRequestStream())
{
str.Write(data, 0, data.Length);
}
WebResponse response = request.GetResponse();
return response.GetResponseStream();
}
catch(WebException e)
{
throw new CmisException(uri, "There was a problem submitting the PUT request.", e);
}
}
04-21-2009 06:01 AM
04-22-2009 09:50 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.