I am trying to create a document inside a plugin code and write data into it. Could someone please help.
Regards,
Soujanya
Discussion posts and replies are publicly visible
Long documentId = 123L; String filePath = cs.getInternalFilename(cs.getVersion(documentId,ContentConstants.VERSION_CURRENT)); /* you will get something like, C:\appian\_admin\accdocs1\1\10000001.pdf */ File jAppianFile = new File(filePath);
Thanks,
Raghu
Hi Pradeep,
You have to upload document using a!fileUploadField. You can save Document Id in local variable to process it further.
Please have a look at following code.
a!fileUploadField( label: "File Upload", labelPosition: "ABOVE", saveInto: { local!docId }, validations: {} )
Hey,
You can try using the upload method from ContentService
ContentOutputStream upload(Document doc,
java.lang.Integer unique)
throws InvalidContentException,
StorageLimitException,
PrivilegeException,
InsufficientNameUniquenessException,
DuplicateUuidException
Creates a document and provides an output stream to which the document's content should be written. The document is created using the createApproval(Content, Integer) API. The caller must write the document's data to the returned output stream and complete the upload by calling ContentOutputStream.close(). Invoking the stream's close method will calculate the size of the data written to the stream and save it as metadata for the document.
the stream returned can be used to write like any other plain java stream.
for more details, check the ContentService public API definition from developers tab of community.
Hope this helps!