Apu*_*ius 3 javascript google-api google-drive-api google-api-js-client
通过完整范围的 OAuth 成功验证后:
https://www.googleapis.com/auth/drive`
Run Code Online (Sandbox Code Playgroud)
我根据创建文件夹中的示例创建了一个文件夹
var fileMetadata = {
'name' : name,
'mimeType' : 'application/vnd.google-apps.folder',
// 'parents': [ parent ]
};
gapi.client.drive.files.create({
resource: fileMetadata,
fields: 'id'
}, function(err, file) {
if(err) {
// Handle error
console.log(err);
} else {
console.log('Folder Id: ', file.id);
return file.id;
}
});
Run Code Online (Sandbox Code Playgroud)
回调函数永远不会被调用,控制台中没有错误。
我怎样才能知道发生了什么?
我最终使用了较低级别的gapi.client.request方法,该方法工作可靠。
var body= {"name": name,
"mimeType": "application/vnd.google-apps.folder",
"parents": [parent.id]}
gapi.client.request({
'path': 'https://www.googleapis.com/drive/v3/files/',
'method': 'POST',
'body': body
}).then(function(jsonResp,rawResp) {
console.log(jsonResp)
if (jsonResp.status==200) {
callback(jsonResp.result)
}
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
896 次 |
| 最近记录: |