I am trying to fetch the content of the uploded document but I am getting the contentReader value as null.How to get the uploaded document content on onCreateNode method?Below is the code snippet that I was implemented
public void onCreateNode(ChildAssociationRef parentChildAssocRef) {
logger.info("Inside onCreateNode");
NodeRef parentFolderRef = parentChildAssocRef.getParentRef();
NodeRef docRef = parentChildAssocRef.getChildRef();
System.out.println("onCreateNode NodeRef "+docRef);
ContentReader reader = this.getContentService().getReader(docRef, ContentModel.PROP_CONTENT);
System.out.println("onCreateNode Reader "+reader);
}
This behaviour validates electronic signatures on a file:
I guess you should listen to "onContentUpdate" policy instead of "onCreateNode" one.
I changed the NotificationFrequency to TRANSACTION_COMMIT in onCreateNode then I am not getting the contentReader value as null but while to am trying to fetch the content as a stream object then I am facing issue as ContentIOException.
Caused by: org.alfresco.service.cmr.repository.ContentIOException: 00190021 Failed to open stream onto channel:
dms-impl-acs_1 | accessor: ContentAccessor[ contentUrl=store://2021/1/19/18/47/7d2e073a-43b0-4e7d-8caa-aa180047be66.bin, mimetype=image/png, size=158162, encoding=UTF-8, locale=en_GB]
Below is the code snippet
public void onCreateNode(ChildAssociationRef parentChildAssocRef) {
logger.info("Inside onCreateNode");
NodeRef parentFolderRef = parentChildAssocRef.getParentRef();
NodeRef docRef = parentChildAssocRef.getChildRef();
System.out.println("onCreateNode NodeRef "+docRef);
ContentReader reader = this.getContentService().getReader(docRef, ContentModel.PROP_CONTENT);
System.out.println("onCreateNode Reader "+reader);
InputStream originalInputStream = reader.getContentInputStream();
System.out.println("originalInputStream "+originalInputStream);
}
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.