在Google云端硬盘上标记为不公开的公开文件无法通过API检索

时间:2014-09-09 00:31:12

标签: javascript google-drive-api

我有两个文件,一个被标记为完全公开,一个被标记为不公开(即只有那些带链接的人可以加载它)。

公开并列出:https://docs.google.com/file/d/0Bzim72JjnlIWRFlURmRrX3N6NEE/edit

公开和不公开:https://docs.google.com/file/d/0Bzim72JjnlIWZHBwSFF0STRNNGc/edit

从我在docs中阅读的所有内容中,我应该能够通过API使用api密钥检索这两个文件的元数据。但是,我只能检索完全公开的文件。为什么呢?

这是我可以复制并粘贴到javascript控制台的测试代码:

//text.txt, open to everyone
//https://docs.google.com/file/d/0Bzim72JjnlIWRFlURmRrX3N6NEE/edit
var xhr1 = new XMLHttpRequest();
xhr1.open("get", "https://www.googleapis.com/drive/v2/files/0Bzim72JjnlIWRFlURmRrX3N6NEE?key=AIzaSyDo66jOFuHllu3r3PwKcZaUd7N9ho9l9WU");
xhr1.onreadystatechange = function(){
    if(xhr1.readyState === 4){
        //will be true (status 200)
        console.log("text.txt metadata retrieved? " + (xhr1.status === 200));
    }
};
xhr1.send();

//text2.txt, open to just those with link
//https://docs.google.com/file/d/0Bzim72JjnlIWZHBwSFF0STRNNGc/edit
var xhr2 = new XMLHttpRequest();
xhr2.open("get", "https://www.googleapis.com/drive/v2/files/0Bzim72JjnlIWZHBwSFF0STRNNGc?key=AIzaSyDo66jOFuHllu3r3PwKcZaUd7N9ho9l9WU");
xhr2.onreadystatechange = function(){
    if(xhr2.readyState === 4){
        //will be false (status 404 Not Found)
        console.log("text2.txt metadata retrieved? " + (xhr2.status === 200));
    }
};
xhr2.send();

0 个答案:

没有答案