22import warnings
33from pathlib import Path
44from time import sleep
5+ from typing import Union , Optional
56from urllib .parse import quote , urlparse
7+ from io import BytesIO
68
79from dateutil .parser import parse
810
3133
3234class DownloadableMixin :
3335
34- def download (self , to_path = None , name = None , chunk_size = 'auto' ,
35- convert_to_pdf = False , output = None ):
36+ def download (self , to_path : Union [None , str , Path ] = None , name : str = None ,
37+ chunk_size : Union [str , int ] = 'auto' , convert_to_pdf : bool = False ,
38+ output : Optional [BytesIO ] = None ):
3639 """ Downloads this file to the local drive. Can download the
3740 file in chunks with multiple requests to the server.
3841
@@ -45,7 +48,7 @@ def download(self, to_path=None, name=None, chunk_size='auto',
4548 however only 1 request)
4649 :param bool convert_to_pdf: will try to download the converted pdf
4750 if file extension in ALLOWED_PDF_EXTENSIONS
48- :param RawIOBase output: (optional) an opened io object to write to.
51+ :param BytesIO output: (optional) an opened io object to write to.
4952 if set, the to_path and name will be ignored
5053 :return: Success / Failure
5154 :rtype: bool
@@ -309,17 +312,17 @@ def restore(self):
309312
310313 return bool (response )
311314
312- def download (self , to_path = None , name = None , chunk_size = 'auto' ,
313- convert_to_pdf = False ):
315+ def download (self , to_path : Union [None , str , Path ] = None , name : str = None ,
316+ chunk_size : Union [str , int ] = 'auto' , convert_to_pdf : bool = False ,
317+ output : Optional [BytesIO ] = None ):
314318 """ Downloads this version.
315319 You can not download the current version (last one).
316320
317321 :return: Success / Failure
318322 :rtype: bool
319323 """
320- return super ().download (to_path = to_path , name = name ,
321- chunk_size = chunk_size ,
322- convert_to_pdf = convert_to_pdf )
324+ return super ().download (to_path = to_path , name = name , chunk_size = chunk_size ,
325+ convert_to_pdf = convert_to_pdf , output = output )
323326
324327
325328class DriveItemPermission (ApiComponent ):
0 commit comments