问题
I have a google apps script bounded to a spreadsheet, and I created a html form to upload csv and excel files to process them and load the data to the spreadsheet. Everything worked fine in the last 2 years, but since March 2020 the file uploading fails.
When I submit the upload form, I got the following message:
We're sorry, a server error occurred. Please wait a bit and try again.
I checked and the the server-side function is not even called. If I remove the file input field from the form, then everything works fine. I mean the server-side function is called, but of course it hasn't got the file blob...
I didn't modified the script in the last half year, so I thought something changed in the google.script.run function, but I haven't found anything about that.
I also thought that maybe the file has problems, so I tried other files, which I already uploaded, but I got the same error.
Here is my form:
<form id="uploadForm" onsubmit="uploadCsvClient(this)">
<input name="fileToUpload" type="file"/>
<input type="submit" value="Upload"/>
</form>
The client side script:
function uploadCsvClient(formObject) {
google.script.run.withSuccessHandler(uploadSuccess)
.withFailureHandler(onFailure)
.uploadCsv(formObject);
}
Do you know about that something is changed in GAS? What could be the problem? I'm totally lost, so I would really appreciate any help...
回答1:
Meanwhile I found that this is a bug related to the new V8 runtime (https://issuetracker.google.com/issues/149980602)
Maybe I accidentally enabled the new V8 runtime.. (or they automatically enabled it)
So the solution is (until they fix the bug) to disable the V8 runtime or here is a workaround in Tanaike's answer.
来源:https://stackoverflow.com/questions/61931812/google-script-run-fails-in-case-of-file-input