Bor*_*kov 5 javascript google-drive-api
我尝试使用Google云端硬盘文档中的示例.所以代码是:
var request = gapi.client.drive.files.delete({
'fileId' : someFileId
});
request.execute(function(resp)
{
console.log(resp);
});
Run Code Online (Sandbox Code Playgroud)
应用程序安装正确,我正在使用drive.file范围.问题是该文件未被删除.它仍然存在于Drive UI中,无法再打开或下载.文件已损坏.
正在发送的请求不是文档中所述的DELETE https://www.googleapis.com/drive/v2/files/fileId.这是一个POST https://www.googleapis.com/rpc?key=API_KEY.正文包含一个JSON数组:
[{"jsonrpc":"2.0","id":"gapiRpc","method":"drive.files.delete","params":{"fileId":"someFileId"},"apiVersion":"v2"}]
Run Code Online (Sandbox Code Playgroud)
Response包含一个空的JSON对象.响应中没有错误,页面中没有JS错误.API Explorer成功删除了该文件.
任何提示?
小智 5
请尝试使用XMLHttpRequest:
var xmlReq = new XMLHttpRequest();
xmlReq.open('DELETE', 'https://www.googleapis.com/drive/v2/files/' + fileId + '?key=' + apiKey);
xmlReq.setRequestHeader('Authorization', 'Bearer ' + accessToken);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
930 次 |
| 最近记录: |