I have a react app that communicates with a node server to upload a file using Multer. The app size uses a form data.append as shown below..
const data = new FormData();
data.append('file', this.state.fileData);
const requestOptions = {
method: "POST",
body: data,
};
Later I send the form data via ajax to the node server. Via a fetch and promise.
All works really well under the following circumstances.
- The photo is uploaded from FireFox on my mac.
- The photo is uploaded from the camera roll on my iphone and I've said to use a smaller version (like 500kb)
- The filesize on my mac can be very very large without troubles.
WHEN IT DOESNT WORK
- If I select a photo from my phone and use original size
- If I use the camera and take a photo (instead of selecting from camera roll)
I've put an alert into the script to see if it even hits the server, and it appears it doesn't enter the fetch function when the filesize is large.
Ignore the console log and trace information below... but this is the fetch function
fetch(config().apiURL+'/capsulecontent/'+this.state.id, requestOptions)
.then(response => {
alert("received response"); // doesn't fire on large file upload
if(response.status == 200)
{
alert("uploaded ok");
} else {
alert("error on api");
alert(JSON.stringify(response));
}
});