使用谷歌api 从谷歌drive A文件夹拷贝 googlesheet 到B文件夹 文件大于6MB 报错 HttpError 500

问题遇到的现象和发生背景

使用谷歌api 从谷歌drive A文件夹拷贝 googlesheet 到B文件夹 文件大于6MB 报错 HttpError 500

遇到的现象和发生背景,请写出第一个错误信息

用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%

SCOPES = [
        "https://www.googleapis.com/auth/drive",
        "https://www.googleapis.com/auth/drive.file",
        "https://www.googleapis.com/auth/drive.appdata",
        "https://www.googleapis.com/auth/drive.photos.readonly"
    ]
    creds = None
    token_json = os.path.dirname(__file__) + '/token.json'
    client_secrets_json = os.path.dirname(__file__) + '/client_secrets.json'
    if os.path.exists(token_json):
        creds = Credentials.from_authorized_user_file(token_json, SCOPES)
        print('creds', creds)
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            while True:
                try:
                    creds.refresh(Request())
                    break
                except ssl.SSLEOFError:
                    time.sleep(2)

        else:
            flow = InstalledAppFlow.from_client_secrets_file(client_secrets_json, SCOPES)
            creds = flow.run_local_server(port=0)
        with open(token_json, 'w') as token:
            token.write(creds.to_json())
    socket.setdefaulttimeout(600)
    service = build('drive', 'v3', credentials=creds)
    service.files().copy(fileId=copy_file_key,
                         body={"name": copy_to_name,
                               "parents": [to_file_id],
                               "stream": True
                               }).execute()
运行结果及详细报错内容

googleapiclient.errors.HttpError:

我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%

尝试 socket.setdefaulttimeout(600) 这个不太行
也尝试缩小拷贝google sheet 文件,缩小后脚本可以使用

我想要达到的结果,如果你需要快速回答,请尝试 “付费悬赏”

谁能帮帮我
把一个比较大的Google sheet 从Googledrive A 文件目录下,拷贝到Googledrive B文件目录下

您可以采取几个步骤来尝试解决您遇到的 HTTP 500 错误问题:

  • 确保您已在 Google Cloud Console 中为您的项目授权 Google Sheets API 和 Google Drive API。
  • 检查请求的结构以确保其格式正确并且包含所有必需的参数。
  • 如果您尝试复制的文件大于 6MB,您可能需要使用resumableUploadGoogle Drive API 的方法而不是create方法。此方法允许您执行可恢复上传,这对于上传大文件或通过不可靠的网络连接上传文件很有用。
  • 如果问题仍然存在,则可能是 Google Sheets 或 Google Drive API 出现了暂时性问题。在这种情况下,您可能需要稍等片刻后重试,或联系 Google Cloud 支持以获得进一步帮助。