我使用rest api" https://www.googleapis.com/drive/v3/files/fileId/export" " reference page"获取谷歌文档
当我尝试获取有json错误的文件时,我的文档大小约为5 MB:
created : function() {
this.fetchUsers();
},
methods: {
fetchUsers: function() {
var self = this;
fetch('/assets/data/radfaces.json')
.then(function(response) { return response.json()
.then( function(data) { self.users = data; } );
})
.catch(function(error) {
console.log(error);
});
}
}
有没有办法解决这个错误?
答案 0 :(得分:2)
您可以在Files: list中请求exportLinks
字段来代替使用此导出终结点:
curl \
'https://www.googleapis.com/drive/v3/files/[FILE_ID]?fields=exportLinks' \
--header 'Authorization: Bearer [ACCESS_TOKEN]' \
--header 'Accept: application/json'
这将返回类似这样的内容(这些是我为Google幻灯片演示文稿获得的链接):
{
"exportLinks": {
"application/vnd.oasis.opendocument.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=odp",
"application/pdf": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pdf",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pptx",
"text/plain": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=txt"
}
}
这些URL的大小没有严格限制(我能够获得约50mb的PDF)