HTML service: Downloading files Follow
In some HTML scenarios you might need to download attachments / files from the page.
For example, clicking on a link causes the browser to download a file.
Trigger conditions
A download will be triggered once the page content changes and the "Content-Disposition: Attachment" header exists in the response.
Download location
Downloaded files will be saved to your ServiceManager's temp folder (LOCAL_FOLDER/temp) in the following naming convention: <millis_timestamp>.<extension>
The extension will be determined according to the filename in the "Content-Disposition" header, or according to the URL.
Service configuration
You may configure the response of HTML service to return the paths of downloaded files, by manually adding one or more of the following output parameters:
- AP_DOWNLOADS: to return the full local path(s) of the downloaded file(s).
- AP_EXPORTS: to return relative URL(s) for external access to the downloaded file(s).
To manually add an output parameter to a service, open the service in edit mode and click on the "+" button in the "Output Parameters" section.
Service output
The service will return the path(s)/URL(s) to the file in the dedicated output parameters.
If more than one file was downloaded, the values will be separated via ";" (semicolon)
To download the file with your browser, add your hostname as prefix to the AP_EXPORTS value.
e.g. http://localhost:8080/ServiceManager/Macro/FileManager?file=1572640898038.txt&delete=true
&delete=true suffix may be appended to delete the file immediately after download - you will be able to access the file only once.
The default behavior of your browser for the above link will be to open the "Save as" dialog to download the file. If you want the browser to try and open the attachment in an inline viewer (may be relevant to PDF files), add "&inline=true" to the url.
Comments
0 comments
Please sign in to leave a comment.