google.script.run fails in case of file input

回眸只為那壹抹淺笑 提交于 2021-01-28 05:32:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!