【发布时间】:2020-05-05 19:19:02
【问题描述】:
这是我的问题:
我想创建一个谷歌表格扩展,我基本上从谷歌表格中的表格中提取数据,我使用节点 JS 中的方法对其进行修改。 然后,将我修改的数据放在一个字符串中,我想将该字符串上传到客户端的驱动器中,以 csv 或 xml 文件的形式。因此我没有可以用来上传文件的本地文件,只有一个字符串变量。 如何上传该字符串? 非常感谢,这是我的第一个应用程序,我有点挣扎。
代码
const {google} = require ('googleapis');
const keys = require ('./keys.json');
const client = new google.auth.JWT(
keys.client_email, null,
keys.private_key,
['googleapis.com/auth/drive'],
'https://www.googleapis.com/…'
);
client.authorize(function(err, tokens){
if (err){
console.log(err);
return
} else {
console.log('Connected');
gsrun(client);
}
});
async function gsrun(cl) {
const gsapi = google.sheets({version: 'v4', auth: cl});
}
【问题讨论】:
-
为了正确理解您访问Drive API和Sheets API的方法,您能否提供您当前的脚本?当然,请删除您的个人信息。
-
我的 js 文件:const {google} = require ('googleapis');常量键 = 要求 ('./keys.json'); const client = new google.auth.JWT(keys.client_email, null, keys.private_key, ['googleapis.com/auth/drive','https://www.googleapis.com/…); client.authorize(function(err, tokens){ if (err){ console.log(err); return } else { console.log('Connected'); gsrun(client); } });异步函数 gsrun(cl) { const gsapi = google.sheets({version: 'v4', auth: cl}); }
标签: javascript node.js json vue.js google-api-nodejs-client