(cls, input_file, adr, ftkey,
               seekpos=0, reporthook=None)
return send_size
Uploads the data in the file **input_file** to the TS3 server listening
        at the address **adr**. **ftkey** is used to authenticate the file
        transfer.

        When the upload begins, the *get pointer* of the **input_file** is set
        to seekpos.

        If the **reporthook** function (lambda send_size, block_size, total_size)
        is provided, it is called after sending a block to the server.
Uploads the data in the file **input_file** to the TS3 server listening
        at the address **adr**. **ftkey** is used to authenticate the file
        transfer.
Uploads the data in the file ** input_file ** to the TS3 server listening at the address ** adr ** . ** ftkey ** is used to authenticate the file transfer .
def upload(cls, input_file, adr, ftkey,
               seekpos=0, reporthook=None):
        """
        Uploads the data in the file **input_file** to the TS3 server listening
        at the address **adr**. **ftkey** is used to authenticate the file
        transfer.

        When the upload begins, the *get pointer* of the **input_file** is set
        to seekpos.

        If the **reporthook** function (lambda send_size, block_size, total_size)
        is provided, it is called after sending a block to the server.
        """
        if isinstance(ftkey, str):
            ftkey = ftkey.encode()

        # Get the total size of the file and put the get pointer to the correct
        # position.
        input_file.seek(0, 2)
        total_size = input_file.tell()
        input_file.seek(seekpos)

        send_size = seekpos
        block_size = 4096
        try:
            with socket.create_connection(adr) as sock:
                sock.sendall(ftkey)

                # Begin with the upload
                if reporthook is not None:
                    reporthook(send_size, block_size, total_size)

                while True:
                    data = input_file.read(block_size)
                    sock.sendall(data)

                    send_size += len(data)
                    if reporthook is not None:
                        reporthook(send_size, block_size, total_size)

                    if not data:
                        break
        except OSError:
            raise TS3FtUploadError(send_size, err)

        # Raise an error, if the upload is not complete.
        if send_size < total_size:
            raise TS3FtUploadError(send_size)
        return send_size
def upload ( cls , input_file , adr , ftkey , seekpos = 0 , reporthook = None ) : if isinstance ( ftkey , str ) : ftkey = ftkey . encode ( ) # Get the total size of the file and put the get pointer to the correct # position. input_file . seek ( 0 , 2 ) total_size = input_file . tell ( ) input_file . seek ( seekpos ) send_size = seekpos block_size = 4096 try : with socket . create_connection ( adr ) as sock : sock . sendall ( ftkey ) # Begin with the upload if reporthook is not None : reporthook ( send_size , block_size , total_size ) while True : data = input_file . read ( block_size ) sock . sendall ( data ) send_size += len ( data ) if reporthook is not None : reporthook ( send_size , block_size , total_size ) if not data : break except OSError : raise TS3FtUploadError ( send_size , err ) # Raise an error, if the upload is not complete. if send_size < total_size : raise TS3FtUploadError ( send_size ) return send_size