Skip to content

Commit d0134ce

Browse files
authored
Added a custom chunksize to the GetContentFile method. (#50)
* Added a custom chunksize to the GetContentFile method. * Fixed formatting with black
1 parent c739ba3 commit d0134ce

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pydrive2/files.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,12 @@ def GetContentString(
308308

309309
@LoadAuth
310310
def GetContentFile(
311-
self, filename, mimetype=None, remove_bom=False, callback=None
311+
self,
312+
filename,
313+
mimetype=None,
314+
remove_bom=False,
315+
callback=None,
316+
chunksize=DEFAULT_CHUNK_SIZE,
312317
):
313318
"""Save content of this file as a local file.
314319
@@ -320,6 +325,8 @@ def GetContentFile(
320325
:type remove_bom: bool
321326
:param callback: passed two arguments: (total trasferred, file size).
322327
:type param: callable
328+
:param chunksize: chunksize in bytes (standard 100 MB(1024*1024*100))
329+
:type chunksize: int
323330
:raises: ApiRequestError, FileNotUploadedError
324331
"""
325332
files = self.auth.service.files()
@@ -328,7 +335,9 @@ def GetContentFile(
328335
raise FileNotUploadedError()
329336

330337
def download(fd, request):
331-
downloader = MediaIoBaseDownload(fd, self._WrapRequest(request))
338+
downloader = MediaIoBaseDownload(
339+
fd, self._WrapRequest(request), chunksize=chunksize
340+
)
332341
done = False
333342
while done is False:
334343
status, done = downloader.next_chunk()

0 commit comments

Comments
 (0)