I've tried following https://stackoverflow.com/a/40714217/9957948 and https://stackoverflow.com/a/35206069/9957948 with no success. I am still getting Network request failed
.
Here is my cURL request that works:
curl -X POST "url" -H "Content-Type: multipart/form-data; boundary=--CUSTOM" -H "Content-Length: 237" -d $'----CUSTOM\nContent-Disposition: form-data; name="fileToUpload"; filename="t006"\nContent-Type: application/octet-stream\n\nset shiftwidth=4\nset autoindent\n\n----CUSTOM\nContent-Disposition: form-data; name="submit"\n\nUpload Image\n----CUSTOM--\n'
And here is what I tried to convert it to, and it is returning Network request failed.
uploadFile(){
const formData = new FormData()
formData.append('blob', new Blob(['set shiftwidth=4\nset autoindent\n']), 't006')
fetch('url', {
method: 'POST',
body: formData
})
.then(data => {
console.log(data)
})
.catch(error => {
console.log('error:' + error.message);
})
Is Content-Length
or the body Content-Type: application/octet-stream
required?
I'm fairly new to all this so any help would be appreciated. Thanks