Closed pjesek closed 3 years ago
you need to include the FormData boundary headers:
const formData = new FormData();
formData.append('file', req.files.file);
formData.append('api', API_KEY);
axios.post('https://api.mineskin.org/generate/upload', formData, {
headers: formData.getHeaders()
}).then((res) => {
console.log(`Status: ${res.status}`);
console.log('Body: ', res.data);
}).catch((err) => {
console.error(err);
})
you need to include the FormData boundary headers:
const formData = new FormData(); formData.append('file', req.files.file); formData.append('api', API_KEY); axios.post('https://api.mineskin.org/generate/upload', formData, { headers: formData.getHeaders() }).then((res) => { console.log(`Status: ${res.status}`); console.log('Body: ', res.data); }).catch((err) => { console.error(err); })
still same error unluckily
try removing the formData from the argument list and add it as body: formData
below headers
try removing the formData from the argument list and add it as
body: formData
below headers
Same error appears. There's something with file, maybe cause I've already requested it through react client to express server Here's the frontend (react) side:
fileUploadHandler = () => {
const formData = new FormData();
formData.append('file', this.state.selectedFile);
try {
axios.post('/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data'
},
});
console.log('File Uploaded');
} catch (err) {
if (err.response.status === 500) {
console.log('There was a problem with the server');
} else {
console.log(err.response.data.msg);
}
}
}
I also console logged an uploaded file object on express side, where this error appears. (Maybe that will help with finding the problem)
{
name: 'e00f06e2b715fec1.png',
data: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 40 00 00 00 40 08 03 00 00 00 9d b7 81 ec 00 00 02 1f 50 4c 54 45 00 00 00 00 00 00 00 a4 f6 ... 1486 more bytes>,
size: 1536,
encoding: '7bit',
tempFilePath: '',
truncated: false,
mimetype: 'image/png',
md5: '7df6d883759491df028ed2c0a4edb7c8',
mv: [Function: mv]
}
Okay, so there's an error with the /generate/upload endpoint. I used rest.wiki upload, even when i chose a skin file after executing it the error appears:
{
"error": "missing files"
}
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Hi, I have a problem with making a POST request to Mineskin API and it's getting trouble with reading a file object. Maybe it's not that related issue but it could help everyone in the future.
Here's the error:
Here's what I've actually made. Any solutions? i tried everything.