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
  • @shivamg

    Upload method is a sophisticated way to create/upload a document into the KC.

    Initially when I was not aware about the Upload method I used to follow the below crude procedure to upload a document into the KC.

    1.\tCreate a document using create method which returns you the document id but this method does not create the file on disk.
    \tHere you need to set the state, name , size , fileSystemId , etc according to your requirements.
    \t
    2. Next what you have to do is read the data from the orginal document(which you intend to upload into the KC) and write it into document you created in Step 1. You can get the file path using getInternalFilename and create a outstream and then write the desired data.

    With the completion of step 2 your file will be already present in the KC.

    Let me know if this information was helpful.
Reply
  • @shivamg

    Upload method is a sophisticated way to create/upload a document into the KC.

    Initially when I was not aware about the Upload method I used to follow the below crude procedure to upload a document into the KC.

    1.\tCreate a document using create method which returns you the document id but this method does not create the file on disk.
    \tHere you need to set the state, name , size , fileSystemId , etc according to your requirements.
    \t
    2. Next what you have to do is read the data from the orginal document(which you intend to upload into the KC) and write it into document you created in Step 1. You can get the file path using getInternalFilename and create a outstream and then write the desired data.

    With the completion of step 2 your file will be already present in the KC.

    Let me know if this information was helpful.
Children
No Data