0

There doesn't seem to be an input component for uploading files and I can't manage to edit the existing ImageInput to work either. If anyone has any examples of how to upload non-image files I'd greatly appreciate it.

okeefj22
  • 31
  • 3

2 Answers2

0

Do you mean uploading to a web server? Try using an input tag with the type attribute set to "file".

<input type="file" name=  etc>
Nimantha
  • 6,405
  • 6
  • 28
  • 69
0

Right, so I managed to come up with a bit of a workaround. I'm sure there has to be an easier way but this is what worked for my individual case.

I had been using the simpleRestClient whose convertRESTRequestToHTTP function returns the url and options variables which are later passed to fetch. For CREATE cases, it sets them to the following

url = `${apiUrl}/${resource}`;
options.method = 'POST';
options.body = JSON.stringify(params.data);

So it was sending a string as the request body instead of the FormData that my backend was expecting. I had to create a new FormData object and append all the items from params.data. I then attached this form to options.body.

okeefj22
  • 31
  • 3