Hello.
I want to upload a document using the REST API and then I want to show it using a Form.
I've been able to upload the document by using the following class: DocumentServicesClient. Here is my code:
DocumentServicesClient docServices = client.getServicesClient(DocumentServicesClient.class);
// Creates a document into kie-server
DocumentInstance doc = new DocumentInstance();
doc.setIdentifier("Test");
doc.setName("Test");
URL docURL = new URL("http://25.64.146.44:1010/alfresco/api/-default-/public/cmis/versions/1.0/atom/content/RUT_987?id=e066212a-7f11-4220-a2b1-f87b687118de%3B8.0");
doc.setLink(String.valueOf(docURL));
String name = "admin";
String pass = "admin";
String authString = name + ":" + pass;
System.out.println("auth string: " + authString);
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
System.out.println("Base64 encoded auth string: " + authStringEnc);
URLConnection urlConnection = docURL.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic " + authStringEnc);
InputStream is = urlConnection.getInputStream();
byte[] docContent = IOUtils.toByteArray(is);
doc.setContent(docContent);
doc.setSize(docContent.length);
doc.setLastModified(Calendar.getInstance().getTime());
String docId = docServices.createDocument(doc);
The document is created and I can see it using the REST API
Now, I wanna show it by using a user task in a Form. How can I accomplish this?. Is there any way to show the document in a user Form?.
Thank you.