Start a form or flow with an upload control pre-initialized with uploaded file attachments
How do I start a form or flow with an upload control pre-initialized with uploaded file attachments?
The same code works for either a form or workflow. The code assumes the form/flow has an upload control with the name “upload”.
FormTypeEntry ftEntry = …; // See other examples for ways to derive the form type entry of the form/flow
FormEntryBuilder builder = ftEntry.createInstanceBuilder();
// attach several files to a single upload control InputStream in = …; // Get attachment file 1 as input stream somehow builder.attachment("upload", "image/png", “some_filename_1.png", in); // parameters: upload control name, mime content type, the file name, input stream
URL imageUrl = new URL("http://www.example.com/some_image.png”); // get this one remotely builder.attachment("upload", "image/png", imageUrl); // create the form/flow instance FormEntry fEntry = builder.createInstance();
// get the form/flow url to show to the user URL fEntryURL = new URL(fEntry.getFormUseLink().getHref());