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.
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
.