Companyhome Not Defined Error In Bundle Service *.post.js File In Alfresco Share
I have a custom service /hayts the processes file uploads and metadata. the same files work when following the MultiPart Forms Tutorial. However, when I bundle the files into My Sh
Solution 1:
Alfresco and Share and not the same thing as you probably know, Alfresco being the platform and Share being the user interface.
So root object available to either are not the same.
https://docs.alfresco.com/6.1/references/APISurf-rootscoped.html
https://docs.alfresco.com/4.2/references/API-JS-rootscoped.html
Solution 2:
You can use the FileFolderService to create a folder and then a file in this new folder. We use the ServiceRegistry to get to the FileFolderService, The ServiceRegistry bean is injected into the Web Script controller bean.
/**
* Create a file under the passed in folder.
*
* @param folderInfo the folder that the file should be created in
* @param filename the name of the file
* @param fileTxt the content of the file
* @return a FileInfo object with data about the new file, such as NodeRef
*/
private FileInfo createFile(FileInfo folderInfo, String filename, String fileTxt) throws FileExistsException {
// Create the file under passed in folder, the file will be empty to start with
FileInfo fileInfo = serviceRegistry.getFileFolderService().create(
folderInfo.getNodeRef(), filename, ContentModel.TYPE_CONTENT);
// Get the NodeRef for the new file from the FileInfo object
NodeRef newFileNodeRef = fileInfo.getNodeRef();
// Add some content to the file
ContentWriter writer = serviceRegistry.getFileFolderService().getWriter(newFileNodeRef);
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.setEncoding("UTF-8");
writer.putContent(fileTxt);
return fileInfo;
}
Post a Comment for "Companyhome Not Defined Error In Bundle Service *.post.js File In Alfresco Share"