我正在尝试使用C++ rest sdk更新Alfresco服务器文件的内容。我正在使用Alfresco CMIS url发送请求。更具体地说,它是Alfresco CMIS浏览器绑定。我必须坚持使用浏览器绑定而不是原子绑定。
当我发送请求时,它总是更新文件的版本而不是内容。我在请求正文中发送了内容。以下是我的代码:
当我发送请求时,它总是更新文件的版本而不是内容。我在请求正文中发送了内容。以下是我的代码:
void UpdateFileContent()
{
concurrency::streams::basic_istream<unsigned char> fileStream = file_stream<unsigned char>::open_istream("C:\Desktop\Sample.txt").get();
concurrency::streams::stringstreambuf streamBuffer;
fileStream.read_to_end(streamBuffer).get();
std::string textFile = move(streamBuffer.collection());
fileStream.close();
streamBuffer.close();
std::string textBoundary = "--FORMBOUNDARY--";
std::string textBody = "";
textBody += "--" + textBoundary + "\r\n";
textBody += "Content-Disposition:form-data;name=Sample;filename=Sample\r\n";
textBody += "Content-Type: application/octet-stream\r\n\r\n";
textBody +=textFile+"\r\n";
textBody += "--" + textBoundary + "--\r\n";
web::uri_builder builder(U("http://Alfresco-Server:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites/"));
builder.append_path(U("siteName/documentLibrary/FolderName/Sample3.doc"));
builder.append_query(U("alf_ticket"),ticket);
builder.append_query(U("cmisaction"),U("update"));
builder.append_query(U("propertyId[0]"),U("cmis:name"));
builder.append_query(U("propertyValue[0]"),U("SampleFileUpdate"));
http_client client(builder.to_string());
http_request req;
req.set_method(methods::POST);
req.headers().set_content_type(L"multipart/form-data;boundary=--FORMBOUNDARY--");
req.headers().set_content_length(textBody.length());
req.set_body(textBody);
http_response response = client.request(req).get();
std::cout<<response.status_code();
}
如果我将cmisaction更改为createDocument,则相同的代码可用于上传新文件。 请提供一种通过C ++ rest SDK更新存储在alfresco中文件内容的解决方案。