def Push(cls, connection, datafile, filename,
             st_mode=DEFAULT_PUSH_MODE, mtime=0, progress_callback=None):
        """Push a file-like object to the device.

        Args:
          connection: ADB connection
          datafile: File-like object for reading from
          filename: Filename to push to
          st_mode: stat mode for filename
          mtime: modification time
          progress_callback: callback method that accepts filename, bytes_written and total_bytes

        Raises:
          PushFailedError: Raised on push failure.
        """

        fileinfo = ('{},{}'.format(filename, int(st_mode))).encode('utf-8')

        cnxn = FileSyncConnection(connection, b'<2I')
        cnxn.Send(b'SEND', fileinfo)

        if progress_callback:
            total_bytes = os.fstat(datafile.fileno()).st_size if isinstance(datafile, file) else -1
            progress = cls._HandleProgress(lambda current: progress_callback(filename, current, total_bytes))
            next(progress)

        while True:
            data = datafile.read(MAX_PUSH_DATA)
            if data:
                cnxn.Send(b'DATA', data)

                if progress_callback:
                    progress.send(len(data))
            else:
                break

        if mtime == 0:
            mtime = int(time.time())
        # DONE doesn't send data, but it hides the last bit of data in the size
        # field.
        cnxn.Send(b'DONE', size=mtime)
        for cmd_id, _, data in cnxn.ReadUntil((), b'OKAY', b'FAIL'):
            if cmd_id == b'OKAY':
                return
            raise PushFailedError(data)
Push a file-like object to the device.

        Args:
          connection: ADB connection
          datafile: File-like object for reading from
          filename: Filename to push to
          st_mode: stat mode for filename
          mtime: modification time
          progress_callback: callback method that accepts filename, bytes_written and total_bytes

        Raises:
          PushFailedError: Raised on push failure.
        
adb/filesync_protocol.py