Downloading file from Google Drive without problem. I need limit download speed like 512kbps, 1024kbps per second.
Tried to time.sleep(1) and change chunksize but it's not working perfectly. Maybe there is fuction to limit speed.
http = credentials.authorize(httplib2.Http())
drive_service = discovery.build('drive', 'v3', http=http, cache_discovery=False)
request = drive_service.files().get_media(fileId=link)
file = drive_service.files().get(fileId=link).execute()
dosyadi = file['name']
fh = io.FileIO(yazilacakyer, 'wb')
downloader = MediaIoBaseDownload(fh, request, chunksize=1024 * 1024)
time1 = time.time()
done = False
while done is False:
status, done = downloader.next_chunk()
fark = float(time.time() - time1)
time1 = time.time()
print('Download Speed:')
print(self.byteToKb_or_Mb(int(1024/fark)*1024))