Hi I am trying to upload ms word and excel to alfresco using Java, I made a web application using jsf with Trinidad upload every thing is fine for images and PDF but when uploading word file it uploaded to alfresco, The problem is when I try to downland it the file is corrupted and office couldn't open it.ParentReference parent = connecttoAlfUtils.ReferenceToParent(parentref);
parent.setChildName(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, connecttoAlfUtils.normilizeNodeName(documentProperties.getFileName())));
NamedValue[] properties = new NamedValue[] { Utils.createNamedValue(Constants.PROP_NAME, documentProperties.getFileName()),
// I put content-type static her to test if it works but it does not
Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}content-type", "application/msword"),
Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}creator", documentProperties.getUserName()),
Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}description", documentProperties.getFileDesc())};
CMLCreate create = new CMLCreate("1", parent, null, null, null, Constants.TYPE_CONTENT, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
// Execute the CML create statement
UpdateResult[] results = null;
try {
System.out.println("Creating the document " + documentProperties.getFileName());
results = connecttoAlfUtils.getRepositoryService().update(cml);
document = results[0].getDestination();
} catch (Exception e) {
System.err.println("Can not create the document.");
throw e;
}
// Set the content
ContentFormat format = new ContentFormat(Constants.MIMETYPE_TEXT_PLAIN, "UTF-8");
try {
System.out.println("Setting the content of the document");
connecttoAlfUtils.getContentService().write(document, Constants.PROP_CONTENT, documentProperties.getContent(), format);
isSavedInAlfresco = true;
} catch (Exception e2) {
System.err.println("Can not set the content of the document.");
throw e2;
}