Read a file via Javascript

Hello,
I’m trying to write a javascript component to read a file to make a http request.
Non of the shown file upload components are working.

Can you please show me what commands are used to read a file directly in javascript.
In my use case I’m taking a picture with the flow function, getting a object with the “path” key and trying to read the file to upload it to a custom endpoint.

Thank you

Any progress on this question?

Why not use the Upload Files flow function?

Good question :smile:

The upload files function will put the file in the body.
I need the files to be present in the multipart/form-data.

The upload multiple forms flow function is not working.
I checked the request. My server was not receiving any for the upload multiple files flow function.

The easiest way would be to just read the file in javascript and use the fetch api.

Any change someone can help me here?

There is no direct access to the filesystem from a Javascript node - it requires native calls so you have to use some flow function to get to the file.

I would use the Read file flow function to read the file contents (in base64 for example), and then take that as input to a Javascript node if I wanted to write the upload logic in code myself. You have access to fetch for performing the request itself.

Thank you.
I’m going to try the read file flow function.

Hi @o.ezzat, I’m also trying to follow your flow to upload a file presented as a multipart/form-data.
Did you manage to read the file? Have you got any update/suggestion on the topic?

@Marco_Boretto

Well I rewrote my server to accept a single file in the body as a binary instead of multipart/form-data.
This is just a workaround.
Sorry but this might not be any help for you.

I’m sure the AppGyver Team will fix this sooner than later.

1 Like