Could not find any info on my problem below – so posting.
I am uploading a BLOB to a google-apps-script webapp – code and log below.
e.postData
is missing on the webapp doPost(e)e.parameter.**NewsFile**
is missing- the
e.contentLength
indicates the data is received – checked with 1Mb BLOB - the client side formdata indicates NewsFile is being attached
chrome.devtools
show correct payload sent to server
I am using FormData because I need to programatically attach files/blobs to the send request.
Any ideas/insight greatly appreciated.
// client code
function clientTest() {
const content="<q id="a"><span id="b">hey!</span></q>";
const blob = new Blob([content], { type: "text/xml" });
const formdata = new FormData();
formdata.append("TestKey", "TestValue");
formdata.append("NewsFile", blob);
console.log(`client send info :: ${[...formdata.keys()].join(" | ")}`);
fetch("webappurl", { method: "POST", body: formdata });
}
// client log
// client send info :: TestKey | NewsFile
// server code - google apps script webapp
function doPost(e) {
console.info(`e.keys = ${[...Object.keys(e)].join(" | ")}`);
console.info(`param.keys = ${[...Object.keys(e.parameter)].join(" | ")}`);
console.info(`post.length = ${e.contentLength}`);
}
// server log
// e.keys = parameters | contextPath | parameter | contentLength | queryString | pathInfo
// param.keys = TestKey
// post.length = 684
You need to sign in to view this answers
Leave feedback about this