I am posting data to a service. The data is an image ( base64 ). This works fine when using small images. But when I use bigger ones, I get the following Error: Payload Too Large
How can I code it so that the I can send larger images? Just sending the url of the image is not a option. I have to send the image in base64.
This is my code located in the backend:
export function getImageId(imageData, style) {
//console.log("Getting called");
return new Promise((resolve, reject) => {
imageData = imageData.replace("data:image/png;base64,", "")
console.log(imageData)
var dataPost = {
"styleId": style,
"imageBase64Encoded": imageData,
}
fetch("url", {
method: "post",
headers: {
"x-api-key": "api-key",
"Content-Type": "application/json",
},
body: JSON.stringify(dataPost)
})
.then((httpResponse) => {
console.log(httpResponse.bodyUsed)
if (httpResponse.ok) {
return httpResponse.json();
} else {
return httpResponse.json();
//return Promise.reject("Fetch did not succeed");
}
})
.then((json) => {
console.log("Data")
console.log("Json", json)
resolve(json)
})
.catch((err) => {console.log(err)});
})
}