[Solved] Sending a request using Axios in React via FormData object

Hi, thanks for the plugin.

I have integrated the React version of Uppy and am able to add a file, see a thumbnail and get an array containing my file object. The array has items including an ID, name, type etc.

I am using the FormData class to add the upload with data.append(‘file’, {uri: ‘file://’ + file.id, name: file.name, type: file.type});

However submitting this ends up with just [object Object] in the request body.

I am aware this issue could be with the Axios client, but I am unsure if I am getting data from the upload correctly. Is there a way to get the raw blob or base64 data from a file object in a files list?

Thanks in advance!

I have solved this but will leave this here for someone else. To use a “new FormData()” object to send a file you need to do: “data.append(‘file-input-name’, file.data, file.name)”

This should then translate into a proper request; remember to also set Content-type in your request headers to “multipart/form-data”