title: how to download a large file faster using telethon in telegram?
body: <p>i'm trying to do something that downloads a lot of file from a telegram channel
  the code works well but it takes too long and above all that I have a slow internet connection
  I have this code, I am downloading files that weigh 1gb but it takes a long time for an example to make the download faster?</p>
  <pre><code>from telethon.sync import TelegramClient
  from telethon.tl.functions.messages import GetHistoryRequest
  import datetime
  import os
  
  def get_entity_data(entity_id, limit):
      entity = client.get_entity(entity_id)
      fecha = datetime.datetime.today()
      today = fecha.day
      yesterday = today - 1
      posts = client(GetHistoryRequest(
                     peer=entity,
                     limit=limit,
                     offset_date=None,
                     offset_id=0,
                     max_id=0,
                     min_id=0,
                     add_offset=0,
                     hash=0))
      for post in posts.messages:
          post_day = post.date.day
          if post_day &gt;= yesterday:
              if post.media is not None:
                  try:
                      file_name = post.media.document.attributes[0].file_name
                  except:
                      file_name = post.media.document.attributes[1].file_name
                  directorio = os.getcwd()+'/descargas'
                  if os.path.exists('descargas/'+file_name) == False:
                      print(file_name, 'Descargando...')
                      client.download_media(message=post, file=directorio)
                      print('Archivo descargado.')
  </code></pre>