I am trying to upload file to the s3 bucket via React and I am struggling with 4xx and 5xx :(
Here is my code base:
onChangeHandler = event => {
const data = new FormData();
data.append('data', event.target.files[0], event.target.files[0].name);
axios
.post(
'/api/attachments/temporary',
{
documents: data,
tempDir: this.generateUuid()
},
{
headers: {
'Content-Type': 'multipart/form-data'
}
}
)
.then(data => {
console.log(`data --- `, data);
})
.catch(e => {
console.log(` --- `, e);
});
};
render() {
return (
<input type='file' name='file' onChange={this.onChangeHandler} />
);
}
If I am sending this post I get 500 and this error:
java.io.IOException: UT000036: Connection terminated parsing multipart data
Also I have noticed that documents property is empty:
This is API doc for backend:
How may I fix it? Maybe, I need somehow transform file locally into binary data etc.? We can upload images and .pdf files.
Thanks!