通过googleapis 包和 file.create 调用使用 Google API 根本不起作用。我已经尝试在Google 的 API Explorer中进行相同的调用,并且确实有效。我有点不知所措。
createSheet 调用封装如下:
Google.prototype.createSheet = function(filename, callback) {
var services = google.drive('v3');
services.files.create({
"name" : filename,
"mimeType" : "application/vnd.google-apps.spreadsheet",
"description" : 'auto-generated by the cli',
"auth" : this.auth
}, function(err,response) {
if( err ) {
console.log('Error : unable to create file, ' + err);
return;
} else {
console.dir(response);
}
});
}
...最终结果是,
{ kind: 'drive#file',
id: '0BwWAQdfAgbYzWk5XRFQyODQ0Zmc',
name: 'Untitled',
mimeType: 'application/octet-stream'
}
它缺少文件名和文件类型。
这里的一般框架工作正常,因为我可以获得文件列表并从电子表格中读取。