lib/connector/upload.js
async function requireTransferHelper(){
    // hex write helper already uploaded within current session ?
    // otherwise upload helper
    if (_isTransferWriteHelperUploaded !== true){
        let response = null;

        try{
            ({response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.transferWriteHelper));

        }catch(e){
            _logger.debug(e);
            throw new Error('cannot upload transfer helper function');
        }

        // get transfer encoding
        if (response == 'b'){
            _transferEncoding = 'base64'
        }else if (response == 'h'){
            _transferEncoding = 'hex'
        }else{
            throw new Error('unknown transfer encoding - ' + response);
        }

        // show encoding
        _logger.log('Transfer-Mode: ' + _transferEncoding);

        // set flag
        _isTransferWriteHelperUploaded = true;
    }
}
async function requireTransferHelper(){
    // hex write helper already uploaded within current session ?
    // otherwise upload helper
    if (_isTransferWriteHelperUploaded !== true){
        let response = null;

        try{
            ({response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.command.transferWriteHelper));

        }catch(e){
            _logger.debug(e);
            throw new Error('cannot upload transfer helper function');
        }

        // get transfer encoding
        if (response == 'b'){
            _transferEncoding = 'base64'
        }else if (response == 'h'){
            _transferEncoding = 'hex'
        }else{
            throw new Error('unknown transfer encoding - ' + response);
        }

        // show encoding
        _logger.log('Transfer-Mode: ' + _transferEncoding);

        // set flag
        _isTransferWriteHelperUploaded = true;
    }
}
async function requireTransferHelper ( ) { // hex write helper already uploaded within current session ? // otherwise upload helper if ( _isTransferWriteHelperUploaded !== true ) { let response = null ; try { ( { response } = await _virtualTerminal . executeCommand ( _luaCommandBuilder . command . transferWriteHelper ) ) ; } catch ( e ) { _logger . debug ( e ) ; throw new Error ( 'cannot upload transfer helper function' ) ; } // get transfer encoding if ( response == 'b' ) { _transferEncoding = 'base64' } else if ( response == 'h' ) { _transferEncoding = 'hex' } else { throw new Error ( 'unknown transfer encoding - ' + response ) ; } // show encoding _logger . log ( 'Transfer-Mode: ' + _transferEncoding ) ; // set flag _isTransferWriteHelperUploaded = true ; } }
utility function to upload file transfer helper
utility function to upload file transfer helper