Google Drive文件读取元数据 [英] Google Drive files meta data read
本文介绍了Google Drive文件读取元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用Google Picker在我的webapp上显示谷歌驱动器选定的图像。为了获得图像的web内容,我需要阅读元数据。然而,我收到了一个类似这样的错误。
I am trying to get the google drive selected images displayed on my webapp using Google Picker. In order to get the webcontent of image, I need to read the metadata. However I am getting an error that is something like this
Uncaught TypeError: Cannot read property 'files' of undefined localhost:169
printFile localhost:169
pickerCallback localhost:156
K.Ld default.I.js:103
_.zc cb=gapi.loaded_0:57
_.Ib
这里是我使用的代码
function printFile(fileId) {
var request = gapi.client.drive.files.get({
'fileId': fileId
});
request.execute(function(resp) {
console.log('Title: ' + resp.title);
console.log('Description: ' + resp.description);
console.log('MIME type: ' + resp.mimeType);
});
}
获取图像元数据后,我将使用Webcontent在webapp上显示图像但它只是没有获取元数据。请告诉我如何解决这个错误。
Once I get the metadata of images I will use Webcontent for image display on webapp but its just not getting the metadata. Please tell me how to fix this error.
推荐答案
使用另一段代码工作:
Got it working using another piece of code which is:
function printFile(fileId) {
var theID = fileId;
var request = gapi.client.request({
'path': '/drive/v2/files/'+theID,
'method': 'GET',
});
request.execute(function(resp) {
console.log('Title: ' + resp.title);
console.log('Description: ' + resp.description);
console.log('MIME type: ' + resp.mimeType);
console.log('WebContent: ' + resp.webContentLink);
});
}
这篇关于Google Drive文件读取元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文