Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
27 replies
Subscribers
5 subscribers
Views
7842 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
How to upload fies to Knowledge center via Content Service
Shivam Gupta
over 8 years ago
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
0
Vinod Bongoni
Certified Lead Developer
over 8 years ago
You can use "create" function of content service and pass the document object with the ContentConstants.
Ex: cs.create(baseDoc, ContentConstants.UNIQUE_NONE)
Here, baseDoc is a object of "Document" class and use "import com.appiancorp.suiteapi.knowledge.Document;".
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shivam Gupta
over 8 years ago
so when i try to upload a document fist i have to convert it into a Document(class) and then upload it!!
and i guess 'cs' is the instance of ContentService
when i call create method then i have to call upload method ..?
so it automatically saves files to knowledge center ???
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Sidhant Behura
over 8 years ago
@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.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Vinod Bongoni
Certified Lead Developer
over 8 years ago
Yes Shiva,
1. First you have to create a document object with the content and set the all applicable properties and then use create function to save it in the Appian.
2. Yes, cs is the object of ContentService.
3. No need to use upload method.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shivam Gupta
over 8 years ago
@vinodb ok
so after using create method then file is uploaded to the KC ??
on more ques
ContentConstants.UNIQUE_NONE is like UUID if i am not wrong !!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shivam Gupta
over 8 years ago
@sidhantb
so when u create an instance of document type, does it mean that the instance is present in the KC
also if you can provide me any snapshots that will be very helpful
thanks
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chandolum
A Score Level 1
over 8 years ago
@Shivamg ContentConstants.UNIQUE_NONE will not check for name uniqueness in KC, i.e, suppose you may have a another file/content which is having same name you can refer com.appiancorp.suiteapi.content package from public java api for more details on how to maintain uniqueness for the file
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Sidhant Behura
over 8 years ago
@shivamg- Yes, its creates a document in KC and it returns a document Id too and you can see the document in the specified KC/Folder.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shivam Gupta
over 8 years ago
@sidhantb how to specify KC/folder their
is it possible for u to attach any screen shots here
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Vinod Bongoni
Certified Lead Developer
over 8 years ago
You can also refer the shared components for this functionality. Many of the plugins has this functionality so you can use the code directly and modify it according to your scenario.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>