As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
ChildAssociationRef association = nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, name), ContentModel.TYPE_CONTENT, contentProps);
var newNode = space.createNode(nodeName, contentType);
// Construct CML statement to create content node CMLCreate createDoc = new CMLCreate("ref1", docParent, null, null, null, Constants.createQNameString(SomeCoModel.NAMESPACE_SOMECO_CONTENT_MODEL, getContentType()), contentProps); // Construct CML Block CML cml = new CML(); cml.setCreate(new CMLCreate[] {createDoc}); // Execute CML Block UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setEncoding("UTF-8"); String text = "The quick brown fox jumps over the lazy dog"; writer.putContent(text);
var newDoc = targetFolder.createFile(filename); newDoc.properties.content.write(content); newDoc.properties.content.mimetype = mimetype; newDoc.save();
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService(); ContentFormat contentFormat = new ContentFormat("text/plain", "UTF-8"); String docText = "This is a sample " + getContentType() + " document called " + getContentName(); Content docContentRef = contentService.write(docRef, Constants.PROP_CONTENT, docText.getBytes(), contentFormat);
Shameless plug from the Alfresco Developer Guide: