Google 드라이브에서 대용량 파일을 다운로드 할 때 메모리가 부족합니다. tmp = content.read(1024)
이 작동하지 않겠지 만 해결 방법은 무엇입니까? 감사합니다.MemoryError - Python을 사용하여 Google 드라이브 SDK를 통해 대용량 파일을 다운로드하는 방법
def download_file(service, file_id):
drive_file = service.files().get(fileId=file_id).execute()
download_url = drive_file.get('downloadUrl')
title = drive_file.get('title')
originalFilename = drive_file.get('originalFilename')
if download_url:
resp, content = service._http.request(download_url)
if resp.status == 200:
file = 'tmp.mp4'
with open(file, 'wb') as f:
while True:
tmp = content.read(1024)
if not tmp:
break
f.write(tmp)
return title, file
else:
print 'An error occurred: %s' % resp
return None
else:
return None
@rivero – Radek