code: def stream_copy(source, destination, chunk_size=512 * 1024):
      
      br = 0
      while True:
          chunk = source.read(chunk_size)
          destination.write(chunk)
          br += len(chunk)
          if len(chunk) < chunk_size:
              break
      # END reading output stream
      return br
docs: Copy all data from the source stream into the destination stream in chunks
      of size chunk_size
  
      :return: amount of bytes written