Sends the content of a file to the server.

@param  string  $ftkey
@param  integer $seek
@param  string  $data
@throws TeamSpeak3_Adapter_FileTransfer_Exception
@return void
503909
public function upload($ftkey, $seek, $data)
  {
    $this->init($ftkey);

    $size = strlen($data);
    $seek = intval($seek);
    $pack = 4096;

    TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadStarted", $ftkey, $seek, $size);

    for(;$seek < $size;)
    {
      $rest = $size-$seek;
      $pack = $rest < $pack ? $rest : $pack;
      $buff = substr($data, $seek, $pack);
      $seek = $seek+$pack;

      $this->getTransport()->send($buff);

      TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadProgress", $ftkey, $seek, $size);
    }

    $this->getProfiler()->stop();

    TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadFinished", $ftkey, $seek, $size);

    if($seek < $size)
    {
      throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file upload (" . $seek . " of " . $size . " bytes)");
    }
  }
1183525
public function sendFile($filePath, $fileName = null) {
        if (!file_exists($filePath))
            return false;

        if (empty($fileName))
            $fileName = basename($filePath);

        $this->addHeader("X-Sendfile: $filePath");
        $this->addHeader("Content-type: application/octet-stream");
        $this->addHeader('Content-Disposition: attachment; filename="'.$fileName.'"');
    }
908975
protected function send($data, $sampleRate=1) {
        $sampledData = array();
        if ($sampleRate < 1) {
            foreach ($data as $stat => $value) {
                if ((mt_rand() / mt_getrandmax()) <= $sampleRate) {
                    $sampledData[$stat] = "$value|@$sampleRate";
                }
            }
        } else {
            $sampledData = $data;
        }
        if (empty($sampledData)) { return; }
        try
        {
            if (!empty($this->host)) // if host is configured, send..
            {
                $fp = fsockopen("udp://{$this->host}", $this->port);
                if (! $fp) { return; }
                // make this a non blocking stream
                stream_set_blocking($fp, false);
                foreach ($sampledData as $stat => $value)
                {
                    if (is_array($value))
                    {
                        foreach ($value as $v)
                        {
                            fwrite($fp, "$stat:$v");
                        }
                    }
                    else
                    {
                        fwrite($fp, "$stat:$value");
                    }
                }
                fclose($fp);
            }
        }
        catch (\Exception $e)
        {
        }
    }
922024
public function stream_seek(int $offset, int $whence = SEEK_SET): bool
    {
        return 0 === fseek($this->filePointer, $offset, $whence);
    }
887301
public function onReceive(swoole_server $server, $fd, $from_id, $data)
    {
        try {
            $this->doWork($server, $fd, $data, $from_id);
        } catch (\Exception $e) {
            $server->send($fd, sprintf("Error: %s\nFile: %s \nCode: %s\nLine: %s\r\n\r\n",
                    $e->getMessage(),
                    $e->getFile(),
                    $e->getCode(),
                    $e->getLine()
                )
            );
            $server->close($fd);
        }
    }
1058215
public function putContents($file_name, $data, $mode = FTP_ASCII)
    {
        if (!is_resource($this->resource)) {
            throw new FtpException("Not connected to FTP server. Call connect() or ssl_connect() first.");
        }
        $temp = tmpfile();
        fwrite($temp, $data);
        fseek($temp, 0);
        return $this->fput($file_name, $temp, $mode);
    }
117960
public function write($key, $data)
    {
        if ($data === '' || !$this->_init) {
            return false;
        }

        $key = $this->_key($key);

        if ($this->_setKey($key, true) === false) {
            return false;
        }

        $lineBreak = "\n";

        if ($this->_config['isWindows']) {
            $lineBreak = "\r\n";
        }

        if (!empty($this->_config['serialize'])) {
            if ($this->_config['isWindows']) {
                $data = str_replace('\\', '\\\\\\\\', serialize($data));
            } else {
                $data = serialize($data);
            }
        }

        $duration = $this->_config['duration'];
        $expires = time() + $duration;
        $contents = implode([$expires, $lineBreak, $data, $lineBreak]);

        if ($this->_config['lock']) {
            $this->_File->flock(LOCK_EX);
        }

        $this->_File->rewind();
        $success = $this->_File->ftruncate(0) &&
            $this->_File->fwrite($contents) &&
            $this->_File->fflush();

        if ($this->_config['lock']) {
            $this->_File->flock(LOCK_UN);
        }
        $this->_File = null;

        return $success;
    }
282519
public static function send($eventKey, array $data, $ip = "0.0.0.0")
    {

        $id = self::getId($ip);
        $ventData = [
            '_id'       => $id,
            'eventKey'  => $eventKey,
            'data'      => $data,
            'ip'        => $ip,
        ];
        $exchangeName   = Helper::getExchangeName();
        $rabbitMq       = new RabbitMq($exchangeName);
        $routeKey       = "route_gateway";
        $rabbitMq->send($ventData, $routeKey);
        return $id;
    }
608929
protected function filePutContents(string $fileName, string $data): bool
    {
        return (bool)@file_put_contents($fileName, $data);
    }
1277665
public static void writeOutContent(final byte[] data, final String filename, final String mime) {
        writeOutContent(data, filename, mime, true);
    }
145057
public function sendPluginCmd($plugin, $data)
    {
        $this->execute(
            "plugincmd",
            array(
                "name" => $plugin,
                "data" => $data,
                "targetmode" => Teamspeak::PLUGINCMD_CLIENT,
                "target" => $this->getId()
            )
        );
    }
621758
public function send($data)
  {
    $this->connect();

    @fwrite($this->stream, $data);

    TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataSend", $data);
  }
15111
public function setFile($key, $content = null, $mtime = null)
    {
        if (null === $mtime) {
            $mtime = time();
        }

        $this->files[$key] = array(
            'content' => (string) $content,
            'mtime' => (integer) $mtime,
        );
    }
1155075
public void sendfile(OutputStream os, long offset, long length)
    throws IOException
  {
    if (os instanceof OutputStreamWithBuffer) {
      writeToStream((OutputStreamWithBuffer) os);
    }
    else {
      writeToStream(os);
    }
  }
294470
public function hmSet($key, array $data) {
        $array = ['hmset', $key];

        foreach ($data as $dataKey => $value) {
            $array[] = $dataKey;
            $array[] = $value;
        }

        return $this->send($array);
    }
928411
public function stream_seek($offset, $whence)
    {
        if (! $this->temporaryFileHandle) {
            return false;
        }
        
        return (fseek($this->temporaryFileHandle, $offset, $whence) === 0);
    }
1218482
public function put($local_file, $remote_file, $mode=null)
    {

        if(!is_null($mode)){
            return $this->scpSend($local_path, $remote_path, $mode);
            return true;
        }
        $stream = @fopen("ssh2.sftp://".$this->sftp.$remote_file, 'w');

        if (! $stream){
            throw new \Exception("Could not open file: $remote_file");
        }

        $data_to_send = @file_get_contents($local_file);
        if ($data_to_send === false){
            throw new \Exception("Could not open local file: $local_file.");
        }

        if (@fwrite($stream, $data_to_send) === false){
            throw new \Exception("Could not send data from file: $local_file.");
        }

        @fclose($stream);

        return true;
    }