Why does my Google App script expect a function to be in a file rather than in the script?

时间:2015-07-28 15:53:28

标签: javascript google-apps-script

I keep getting an error in Google App script when running a function with this variable:

Execution failed: TypeError: Cannot find function getContentAsString in object file_here

var doc = DriveApp.getFolderById('*FOLDER_ID*');
doc.createFile(file).getContentAsString();

Any ideas why? What's the proper way to do this?

1 个答案:

答案 0 :(得分:1)

doc.createFile(file).getAs('text/plain').getDataAsString();

or

doc.createFile(file).getBlob().getDataAsString();

https://developers.google.com/apps-script/reference/base/blob