Upload a file to a Google Web Apps with doPost

别说谁变了你拦得住时间么 提交于 2020-01-02 11:03:11

问题


I'm trying to upload a file to a Google Web App with doPost(e), as shown below.

function doPost(e) {
    var blob = e.parameter.myFile;
    DriveApp.createFile(blob);
}

A file is then POSTed to the web app at the client side. The POST has been proved to work correctly with on my own web server.

However the blob variable, in the code above, is not actually a Blob type, it is a string type. How does Google script engine prepare parameter e? Is there a way to make this work?


回答1:


I got the same problem here. An workaround you can do is convert your file to a Base64 string using FileReader(), upload it, and convert it back on server-side before sending it to your Google Drive.

Here's how to encode your file and decode it server-side using Utilities API



来源:https://stackoverflow.com/questions/37356804/upload-a-file-to-a-google-web-apps-with-dopost

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