“资源”对象没有属性“补丁” Drive.API

时间:2019-09-03 05:26:04

标签: python-2.7 maya google-api-python-client

因此,我已经使用驱动器API初始化了服务,我已经上传了一些文件,同时进行了检查,以防万一,将旧文件移到备份文件夹中并重命名,但是当我检索资源时.files我出错了。

drive_service = discovery.build('drive', 'v3', http=http)
serverPath = 1hi1Y6LoXLLZOMKYt8UmjvBWRWUM0timp
new_title = test_upload_1_MASTER_v6.ma

def renameFile(self, serverPath, new_title):
    """
    Args:
        file_id: ID of the file to rename.
        new_title: New title for the file.
    Returns:
        Updated file metadata if successful, None otherwise.
    """

    try:
        file = {'title': new_title}
        print serverPath, new_title
        # Rename the file.
        updated_file = self.drive_service.files()
        updated_file.patch(
                            fileId=serverPath,
                            body=file,
                            fields='title').execute()

        return updated_file

    except errors.HttpError, error:
        print 'An error occurred'

    return None 
#     updated_file.patch(
# AttributeError: 'Resource' object has no attribute 'patch'

0 个答案:

没有答案