问题描述
我有一个绑定到电子表格的google apps脚本,我创建了一个html表单来上载csv和excel文件来处理它们并将数据加载到电子表格中.在过去的两年中,一切正常,但是自2020年3月以来,文件上传失败.
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:
很抱歉,发生服务器错误.请稍等,然后重试.
我检查了服务器端函数,甚至没有调用.如果我从表单中删除文件输入字段,则一切正常.我的意思是调用了服务器端函数,但是当然它没有文件Blob ...
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...
上半年我没有修改脚本,所以我认为 google.script.run 函数有所更改,但是我没有找到任何相关信息.
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.
这是我的表格:
<form id="uploadForm" onsubmit="uploadCsvClient(this)">
<input name="fileToUpload" type="file"/>
<input type="submit" value="Upload"/>
</form>
客户端脚本:
function uploadCsvClient(formObject) {
google.script.run.withSuccessHandler(uploadSuccess)
.withFailureHandler(onFailure)
.uploadCsv(formObject);
}
您知道GAS中的某些更改吗?可能是什么问题呢?我完全迷路了,所以我将非常感谢您的帮助...
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...
推荐答案
同时,我发现这是与新V8运行时相关的错误( https://issuetracker.google.com/issues/149980602 )
Meanwhile I found that this is a bug related to the new V8 runtime (https://issuetracker.google.com/issues/149980602)
也许我不小心启用了新的V8运行时.(或他们自动启用了它)
Maybe I accidentally enabled the new V8 runtime.. (or they automatically enabled it)
因此,解决方案是(直到他们修复错误为止)禁用V8运行时或这是Tanaike的答案中的一种解决方法.
So the solution is (until they fix the bug) to disable the V8 runtime or here is a workaround in Tanaike's answer.
这篇关于如果输入文件,则google.script.run失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!