Pydrive:更改共享驱动器上文件的元数据

问题描述

我正在尝试使用包装的Google Drive API PyDrive创建一个脚本来处理共享驱动器上的许多文件。我可以将文件加载到嵌套字典中很好,但是当我尝试更改元数据时,找不到文件(由ID引用)。这里有几个类似的问题,我想我已经检查并正确尝试了。

我尝试过包含这些参数,似乎在最初获取文件时就达到了目的:

file_list = drive.ListFile({
                            'q': "title contains 'PORTMUZ' and trashed=false",'supportsAllDrives' : True,'includeItemsFromAllDrives' : True,'corpora' : 'drive','driveId' : portmuz_id
                            }).GetList()

这是整个功能,我仍然可以使用它,但是现在将其设置为仅更改名称

def move_to_archive():
for key,data in index.items():
    if index[key]['active'] == False and index[key]['parents'] == alle_leerlingen_id and 'TEST' in key:
        print(key,'is geen huidige leerling meer maar staat nog in de map Portfolio/Alle Leerlingen. Verplaatsen naar archief?')
        if choose() == True:
            file = drive.CreateFile({
                                    'id': index[key]['id']
                                    })
            file['title'] = 'JEP'
            file.Upload(param={
                            'supportsAllDrives' : True,'supportsTeamDrives' : True,'driveId' : portmuz_id
                            })
            index[key]['parents'] == portmuz_archief_id

我已经检查了错误返回的ID,它是正确的。

Traceback (most recent call last):
  File "script3.py",line 135,in <module>
    main()
  File "script3.py",line 124,in main
    move_to_archive()
  File "script3.py",line 96,in move_to_archive
    print(file.FetchMetadata())
  File "C:\Users\ict\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\python38\site-packages\pydrive\auth.py",line 75,in _decorated
    return decoratee(self,*args,**kwargs)
  File "C:\Users\ict\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\python38\site-packages\pydrive\files.py",line 239,in FetchMetadata
    raise ApiRequestError(error)
pydrive.files.ApiRequestError: <HttpError 404 when requesting https://www.googleapis.com/drive/v2/files/1E80Hp4WJI_ivirQ9TJCCzlFU0ykvDsWH?alt=json returned "File not found: 1E80Hp4WJI_ivirQ9TJCCzlFU0ykvDsWH">

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)