Reading local files
In this tutorial you will learn how to read local files, parse their data and use it in actions.
Currently Abstra does not have a file input element, but you can create one with pure HTML:

html
<input class='file-input' type='file' />
css
.file-input {
width: 100%;
height: 100%;
}
Now you should have an file input in your page (feel free to customize it the way you want)

Once the input is in the screen, add and trigger and set its value to
input
. Then add the Javascript Code action that will use the files under event.target.files

With
event.target.files
you can read the file contents and all sort of things.For example you can select a CSV file and parse its contents to use with other action flows.
First add the parser to an
on page start
action that loads the following scripthttps://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.2/papaparse.min.js

Then on the Javascript Action you can paste the following script (note that if your CSV have headers you can set the flag to true)
await new Promise((res, rej) => {
Papa.parse($.event.target.files[0], {
complete: ({ data }) => res(data),
header: false
});
});
Then you can set a variable or do any other actions:

Last modified 11mo ago