I have a form on a page from which I call a sequence that build a csv file. I would like this file to be downloadable directly from client browser after the sequence call. What is the c8o solution ? Thank you
Two possibilities:
1/ Your sequence call returns the URL of the generated CSV file on the Convertigo Server (inside project or workspace) and you create a link in Mobile Builder that points to this URL. Drawback is that user have to right-click the link to download the file or else it may be displayed in browser. I tried to add 'download' attribute to link but I was unsuccessful
2/ Same as above but instead of pointing directly to the CSV file, the link points to a new Convertigo sequence called in .bin (Convertigo requesters), the response will be a binary file that browser will download. This sequence must return a specific XML tag:
<attachment content-type="application/csv" local-url="D:\COMMON\C8O\sc757_64\workspace\DLFile\repository\data.csv" name="data.csv" type="attachment"/>
This method also implies a link the user have to manually click.
You can have more details on how to do it in this sample project : DLFile.car
I am using a JS trick to trigger the click event on the link to automatically perform the file download:
In Mobile Builder HTML :
<a class="class1567759665690" id="csvFile" href="http://localhost:18080/convertigo/projects/DLFile/.bin?__sequence=fileBin&name=data.csv&filePath=D%3A%5CCOMMON%5CC8O%5Csc757_64%5Cworkspace%5CDLFile%5Crepository%5Cdata.csv">data.csv</a>
In a CustomAction component:
setTimeout(() => {
document.getElementById("csvFile").click();
}, 500);
Hope that helps.