Load & parse a CSV file in Forest before sending its data to my API?


Is a drag & drop feature (CSV file) is available in forest admin?


1 Like

Hi @Thomas,

I’m not sure I correctly understand your need here but correct me if I’m wrong.

Are you trying to upload a .csv file to a cloud hosting provider and would like to drag & drop it from your file explorer to a form in Forest Admin? Or are you trying to import data in a collection from a CSV file?

In any case then go to your collection’s file in the ./forest folder and declare the action as follows, precising the field type File.

collection('products', {
  actions: [
      name: 'Upload CSV document',
      type: 'single',
      fields: [{
        field: 'CSV file',
        description: 'A semicolon separated values file stores tabular data pointers (numbers and text) in plain text.',
        type: 'File',
        isRequired: true,

The field will look like this and you’ll be able to drag and drop a CSV file.

For both use cases I outlined, check the advanced examples below

Hey :slight_smile:

Actually, we don’t want to have any CSV stored into some storage, we want it to be parsed and sent into a database.

So let say we have some code which parses it and send it into the database. I was thinking about using a previous version of a go program doing this and maybe call a cloud function (GCP)

So my question is: How can we, from a drag and drop, read the file (buffer?) and send it by making an HTTP Call?

Hope I could make it more clear, sorry :slight_smile:

Thanks :slight_smile:

1 Like

I needed those details, thanks a lot :sweat_smile:

Since the second example - Import data from a CSV file - did not fully suit your need, I’m guessing the database you are talking about is different from the one your Forest Admin backend is connected to.

The example could still help you parse the data of your CSV file, using csv and parse-data-uri npm packages. Now, to fire HTTP calls after an action is triggered I recommend you take a look at setting up webhooks in smart actions.

We did that :slight_smile: It should be working by today so :slight_smile: Thanks

What did we do? We followed your link and once the CSV is loaded, we send it as body (plain/text) in a post request which trigger some backend code on our servers


1 Like

Great and thanks for sharing your implementation :pray:
I will just update the topic’s title for the sake of clarity.

Yes of course! Hope it helps others :slight_smile:

1 Like