Невозможно загрузить ›CSV-файл размером 200 МБ с помощью Python Drive API

Я пытаюсь автоматизировать свои повседневные задачи с помощью API дисковода, и я столкнулся с ошибкой при попытке загрузить файлы большего размера (›300 МБ CSV), тогда как следующий код работает для загрузки файлов меньшего размера (‹ 100 МБ). Добавлено, что я запускаю фрагмент на своей виртуальной машине Debian Linux и никаких проблем с моей виртуальной машины нет.

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import os



gauth = GoogleAuth()
# Try to load saved client credentials if already done
gauth.LoadCredentialsFile("mycreds.txt")


drive_path = '<drive_id>'

data_to_be_uploaded = "my_big_file.csv"
    
# Declared the variable so that it will be uploaded as per the last date
file1 = drive.CreateFile({'title': my_big_csv_data+'.csv',
                          'parents': [{'id': drive_path}]
                          })
file1.SetContentFile(data_to_be_uploaded)
file1.Upload()

Ошибка как следующая

  File "test_code.py", line 72, in <module>
    file1.Upload()
  File "/usr/share/hunch/lib/python3.6/site-packages/pydrive/files.py", line 285, in Upload
    self._FilesInsert(param=param)
  File "/usr/share/hunch/lib/python3.6/site-packages/pydrive/auth.py", line 75, in _decorated
    return decoratee(self, *args, **kwargs)
  File "/usr/share/hunch/lib/python3.6/site-packages/pydrive/files.py", line 369, in _FilesInsert
    http=self.http)
  File "/usr/share/hunch/lib/python3.6/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/share/hunch/lib/python3.6/site-packages/googleapiclient/http.py", line 810, in execute
    _, body = self.next_chunk(http=http, num_retries=num_retries)
  File "/usr/share/hunch/lib/python3.6/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/share/hunch/lib/python3.6/site-packages/googleapiclient/http.py", line 970, in next_chunk
    headers=headers)
  File "/usr/share/hunch/lib/python3.6/site-packages/oauth2client/transport.py", line 175, in new_request
    redirections, connection_type)
  File "/usr/share/hunch/lib/python3.6/site-packages/oauth2client/transport.py", line 282, in request
    connection_type=connection_type)
  File "/usr/share/hunch/lib/python3.6/site-packages/httplib2/__init__.py", line 1994, in request
    cachekey,
  File "/usr/share/hunch/lib/python3.6/site-packages/httplib2/__init__.py", line 1690, in _request
    content,
httplib2.RedirectMissingLocation: Redirected but the response is missing a Location: header.```


person Shabutheen Basha    schedule 06.12.2020    source источник
comment
Если размер файла является проблемой - почему бы вам не попробовать его сжать?   -  person balderman    schedule 06.12.2020
comment
@balderman: Пробовал, но та же ошибка.   -  person Shabutheen Basha    schedule 06.12.2020
comment
Каков размер файла после сжатия?   -  person balderman    schedule 06.12.2020
comment
@balderman: Это около 50 МБ. Но по-прежнему появляется ошибка httplib2.RedirectMissingLocation: Redirected, но в ответе отсутствует заголовок Location :.   -  person Shabutheen Basha    schedule 06.12.2020
comment
см. stackoverflow.com/questions/59815620/   -  person balderman    schedule 06.12.2020
comment
@balderman: Спасибо, решено путем понижения моей версии httplib2 до 0.13.1   -  person Shabutheen Basha    schedule 06.12.2020


Ответы (2)


Для некоторых типов файлов существуют ограничения в 100 МБ.

https://support.google.com/drive/answer/37603?hl=en

person Paul Brennan    schedule 06.12.2020

Решено путем понижения версии моего пакета httplib2 до 0.13.1

Ссылка используется здесь

Спасибо ! @balderman

person Shabutheen Basha    schedule 06.12.2020