edgeCore version: 4.4.2
This Automation step is used to fetch files from the Internet.
Example:
In this example, we are going to fetch a CSV file and an image. You can watch a demo here.
We start by creating two Web Content connections for two websites, one showing a CSV file and another one showing a picture we are going to fetch. This is not required, as we can use the Fetch File step anywhere and without any connection. This is only for the purpose of this example.
Creating a Fetch File step is as easy as copying a link of the file we want to fetch. The next step we are going to add to this script is JS Eval that will convert a Blob (which is the return value of the Fetch File step) to a downloadable file.
The code we are going to use in the JS Eval step is as follows:
var blob = new Blob([scriptVar.CSVfile], {
type: scriptVar.CSVfile.type
});
var url = window.URL.createObjectURL(blob);
var anchor = document.createElement(“a”);
anchor.download = “csvFile.csv”;
anchor.href = url;
anchor.click();
scriptVar.CSVfile represents the value name that we have selected in the Fetch File step.