问题
在团队云端硬盘备份系统的第一阶段,我首先需要扫描给定团队云端硬盘中的文件,以确定要复制哪些文件进行备份。
I (think?) have full permissions over the files & folders of the Team Drive, due to the credentials I use (set to
Owner
in the cloud console).
尽管如此,我的问题是,当我查询 REST API 查找给定团队云端硬盘的文件列表时,结果不符合 documentation 。返回的文件对象仅包含 5 个字段,分别是:
种类
、名称
、id
、mimeType
、teamDriveId
根据提供的文档,我应该会收到更多字段。
下面是我用来查询 API 和输出的代码。
简化来源
credentials = get_credentials() # retrieves and processes app credentials
drive = get_drive_api(credentials) # get the drive API v3 using httplib2 and discovery
query = drive.files().list(
pageSize = 10,
corpora = 'teamDrive',
supportsTeamDriveItems = True,
includeTeamDrives = True,
teamDriveId = "..."
)
results = query.execute() # contact the REST API
files = results.get('files', [])
for file in files:
print(file)
对于给定的团队云端硬盘,输出为
{
'kind': 'drive#file',
'id': '...',
'name': 'filename',
'mimeType': 'application/vnd.google-apps.document',
'teamDriveId': '...'
}
这显然不是 docs 的预期输出.
关于我没有获得完整预期数据的原因有什么见解吗?
最佳答案
要获取资源的所有可用字段,您可以将 fields
设置为 *
。
例如:
query = drive.files().list(
pageSize = 10,
corpora = 'teamDrive',
supportsTeamDriveItems = True,
includeTeamDrives = True,
teamDriveId = "...",
fields="*" # or maybe "files(id,name,capabilities/canShare),nextPageToken"
)
关于google-drive-api - 团队云端硬盘文件的 Google 云端硬盘 REST API 结果不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46180485/