Accessing file uploads
This document describes the technical approach to accessing and using files that were uploaded during form submission.
Files are propagated to all actions in parameters and can be referenced by the input name, for example, file-upload_0_2.
With SaveToJCR Action
File paths are replaced by absolute url after SaveToJCR action executes. The result of asking for "file-upload_0_2" is: exampleUrl;
Which is the URL of the file in JCR.
You are then able to retrieve the file node by making a call:
Without SaveToJCR Action
When files are uploaded, they are saved under the server’s default temporary directory. For Tomcat it would be saved under tmp folder. The file path is provided in the parameters variable of the action. Access it by specifying the name of the file input, for example, file-upload_0_2.
You are able to also access the original file name and file type.
In terms of action ordering, you have full control of how to order actions. When it comes to form submission, there should be no difference as to which action is performed first, actions do not interact with each other.
Code can be adapted to work with raw files directly from tmp folder, in this case SaveToJCR is not required. If a later action requires the file to be in the JCR, SaveToJCR should be placed before said action.