gpt4 book ai didi

google-api - 如何获取完整文件获得Google Drive V3的响应

转载 作者:行者123 更新时间:2023-12-04 05:06:10 25 4
gpt4 key购买 nike

当我执行文件格式化时,默认情况下,Google驱动器v2接缝将返回完整的文件资源。但是,当我针对V3发出相同的请求时,即使文档指出它应返回文件资源,也仅返回部分文件资源。

GET /drive/v2/files/0B5pJkOVaKccEVEsybFA2WjJjQ1k?access_token={Token}

返回完整文件
{
"mimeType": "text/plain",
"version": "416164",
"appDataContents": false,
"thumbnailLink": "https://lh3.googleusercontent.com/UE-d50Sda_j2pT1dzw8Ll1r7W2gYZNrofX2YS-VKG7Ykl4FAqe9NPPNPA3HX3PBdhQ8uow=s220",
"labels": {
"restricted": false,
"starred": false,
"viewed": false,
"hidden": false,
"trashed": false
},
"explicitlyTrashed": false,
"lastModifyingUserName": "Linda Lawton",
"writersCanShare": true,
"owners": [
{
"picture": {
"url": "https://lh5.googleusercontent.com/-a1CWlFnA5xE/AAAAAAAAAAI/AAAAAAAAdVM/sHkU9F-AwwQ/s64/photo.jpg"
},
"kind": "drive#user",
"displayName": "Linda Lawton",
"permissionId": "6030588225573437243",
"isAuthenticatedUser": true,
"emailAddress": "xxxxx@gmail.com"
}
],
"id": "0B5pJkOVaKccEVEsybFA2WjJjQ1k",
"lastModifyingUser": {
"picture": {
"url": "https://lh5.googleusercontent.com/-a1CWlFnA5xE/AAAAAAAAAAI/AAAAAAAAdVM/sHkU9F-AwwQ/s64/photo.jpg"
},
"kind": "drive#user",
"displayName": "Linda Lawton",
"permissionId": "06030588225573437243",
"isAuthenticatedUser": true,
"emailAddress": "xxxxx@gmail.com"
},
"title": "deleteme.txt",
"ownerNames": [
"Linda Lawton"
],
"etag": "\"dyf6dc5nFpQUIZ2nJvOu2LyLJk8/MTQ4MTU0MTI1NzI2MQ\"",
"parents": [
{
"isRoot": true,
"kind": "drive#parentReference",
"id": "0AJpJkOVaKccEUk9PVA",
"selfLink": "https://www.googleapis.com/drive/v2/files/0B5pJkOVaKccEVEsybFA2WjJjQ1k/parents/0AJpJkOVaKccEUk9PVA",
"parentLink": "https://www.googleapis.com/drive/v2/files/0AJpJkOVaKccEUk9PVA"
}
],
"shared": false,
"originalFilename": "deleteme.txt",
"description": "Test Description",
"webContentLink": "https://drive.google.com/uc?id=0B5pJkOVaKccEVEsybFA2WjJjQ1k&export=download",
"editable": true,
"embedLink": "https://drive.google.com/file/d/0B5pJkOVaKccEVEsybFA2WjJjQ1k/preview?usp=drivesdk",
"markedViewedByMeDate": "1970-01-01T00:00:00.000Z",
"quotaBytesUsed": "150",
"modifiedDate": "2016-12-12T11:14:17.261Z",
"createdDate": "2016-12-12T11:14:17.261Z",
"md5Checksum": "8034035d0be478ab4e4c9bed279a5ff6",
"iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_10_text_list.png",
"kind": "drive#file",
"alternateLink": "https://drive.google.com/file/d/0B5pJkOVaKccEVEsybFA2WjJjQ1k/view?usp=drivesdk",
"copyable": true,
"modifiedByMeDate": "2016-12-12T11:14:17.261Z",
"downloadUrl": "https://doc-00-38-docs.googleusercontent.com/docs/securesc/1mngaurn1r7pdnvlih02e6t9l8me2de5/5h0plr5pqk919iiraojovqrovifi85g7/1481702400000/06030588225573437243/06030588225573437243/0B5pJkOVaKccEVEsybFA2WjJjQ1k?e=download&gd=true",
"userPermission": {
"kind": "drive#permission",
"etag": "\"dyf6dc5nFpQUIZ2nJvOu2LyLJk8/-EUeXLzWA6FGgRjCErcDZHhfLzg\"",
"role": "owner",
"type": "user",
"id": "me",
"selfLink": "https://www.googleapis.com/drive/v2/files/0B5pJkOVaKccEVEsybFA2WjJjQ1k/permissions/me"
},
"spaces": [
"drive"
],
"fileExtension": "txt",
"headRevisionId": "0B5pJkOVaKccEMW0yMitzcklkaWtFZ3FIS1l6Q2x5RGpKQkNjPQ",
"selfLink": "https://www.googleapis.com/drive/v2/files/0B5pJkOVaKccEVEsybFA2WjJjQ1k",
"fileSize": "150"
}

但是,当我针对V3发出相同的请求时
GET /drive/v3/files/0B5pJkOVaKccEVEsybFA2WjJjQ1k?access_token={Token}

它仅返回部分元数据
{
"mimeType": "text/plain",
"kind": "drive#file",
"id": "0B5pJkOVaKccEVEsybFA2WjJjQ1k",
"name": "deleteme.txt"
}

我发现通过添加fields参数,我可以从V3请求其他参数。但是我无法找到一种在一个请求中返回所有字段的方法。

fields
Selector specifying a subset of fields to include in the response.
For more information, see the partial response section in the Performance Tips document. Use for better performance.



它的一个获取请求,所以我不关心性能,我只需要查看此文件的所有数据即可。

最佳答案

在文档中进行深入研究后,我设法找到了comment

Use wildcards in field selections, if needed.
For example: fields=items/pagemap/* selects all objects in a pagemap.



所以我尝试了这个。
GET /drive/v3/files/0B5pJkOVaKccEVEsybFA2WjJjQ1k?access_token={Token}&fields=* 

果然它返回了完整的File资源。

解决方案是在请求中添加 fields=*。我个人认为这应该是默认设置。

关于google-api - 如何获取完整文件获得Google Drive V3的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41137628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com