form serializing not working for file type inputs; need unminified code to debug
I realize this is probably not the best place to ask this but I have no other avenues.
Per Google's HTML Service documentation:
If you call a server function with a form element as a parameter, the form becomes a single object with field names as keys and field values as values. The values are all converted to strings, except for the contents of file-input fields, which become Blob objects.
The relevant line in the code is:
function handleFormSubmit(formObject) {
google.script.run.withSuccessHandler(updateUrl).processForm(formObject);
}
And:
<form id="myForm" onsubmit="handleFormSubmit(this)">
<input name="myFile" type="file" />
<input type="submit" value="Submit" />
</form>
The issue is that in our organization (we use G-Suite) the call fails with this JavaScript error:
Exception: Invalid argument: blob
It is failing when trying to upload/serialize the file into a blob.
I know our organization is doing SOMETHING that is preventing the file from being uploaded/serialized. My challenge is that because I cannot find an unminified version of Google's code that is responsible for serializing/uploading the file, I cannot debug the root cause so I cannot identify what the SOMETHING our company is doing so I can talk to the relevant teams to fix.
I did some debugging using Chrome's developer console and this is the closest I can find for where the error is being raised/thrown:
function be(a, b) {
b = Error(b);
b.name = a;
return b
}
-
a="ScriptError" -
b="Exception: Invalid argument: blob"
There is a post on SO on this and I opened an issue but I have not had luck with either:
- https://issuetracker.google.com/issues/141515596
- https://stackoverflow.com/questions/57577487/how-to-pass-file-upload-blob-from-html-form-to-server-side-apps-script/57975137#57975137
I am desperate to find a solution so I am hoping someone can either help me or point me in the right direction.
Expected Behavior
File should be uploaded, form data should be serialized, and sent to Google
Sample URL: https://github.com/gsuitedevs/apps-script-samples/blob/0ec9ff3bd109789668312cc2f0149f8187344b4f/ui/forms/index.html Description:
Actual Behavior
JavaScript error:
Exception: Invalid argument: blob
Steps to Reproduce the Problem
- Publish code as web-app
- Go to web-app
- Select file and submit