How to upload fies to Knowledge center via Content Service

I am working on a plugin creation that uploads a file to Knowledge center from your system
i know that i have to use contentService
but in contentService their is function named "upload(Document doc, java.lang.Integer unique)" which returns ContentOutputStream instance
but i am unable to understand how the document is getting saved into Knowledge center.
Anyone please help struck in this for a while

Thanks in advance

OriginalPostID-235089

  Discussion posts and replies are publicly visible

Parents
  • @sidhantb @vinodb
    when calling the upload method
    ContentOutputStream outStream = cs.upload(doc, arg1);//here cs is an instance of content service

    for that i have to create and instance of content service
    ServiceContext sc = (new ServiceLocator()).getAdministratorServiceContext();
    ContentService cs = ServiceLocator.getContentService(sc);
    which is described in the documentation

    and i got this error
    java.lang.NoClassDefFoundError: Could not initialize class com.appiancorp.services.WebServiceContextFactory
    \tat com.appian.fileupload.FileUploadServlet.doPost(FileUploadServlet.java:99)

Reply
  • @sidhantb @vinodb
    when calling the upload method
    ContentOutputStream outStream = cs.upload(doc, arg1);//here cs is an instance of content service

    for that i have to create and instance of content service
    ServiceContext sc = (new ServiceLocator()).getAdministratorServiceContext();
    ContentService cs = ServiceLocator.getContentService(sc);
    which is described in the documentation

    and i got this error
    java.lang.NoClassDefFoundError: Could not initialize class com.appiancorp.services.WebServiceContextFactory
    \tat com.appian.fileupload.FileUploadServlet.doPost(FileUploadServlet.java:99)

Children
No Data