public function tika($file)
    {
        $text = null;
        try {
            /** @var Response $response */
            $response = $this->put(
                'tika',
                $this->getGuzzleOptions([
                    'headers' => [
                        'Accept' => 'text/plain',
                    ],
                    'body' => file_get_contents($file),
                ])
            );
            $text = $response->getBody();
        } catch (RequestException $e) {
            $msg = sprintf(
                'TikaRestClient was not able to process %s. Response: %s %s.',
                $file,
                $e->getResponse()->getStatusCode(),
                $e->getResponse()->getReasonPhrase()
            );
            // Only available if tika-server was started with --includeStack
            $body = $e->getResponse()->getBody();
            if ($body) {
                $msg .= ' Body: ' . $body;
            }

            Injector::inst()->get(LoggerInterface::class)->info($msg);
        }

        return (string) $text;
    }
public function tika($file)
    {
        $text = null;
        try {
            /** @var Response $response */
            $response = $this->put(
                'tika',
                $this->getGuzzleOptions([
                    'headers' => [
                        'Accept' => 'text/plain',
                    ],
                    'body' => file_get_contents($file),
                ])
            );
            $text = $response->getBody();
        } catch (RequestException $e) {
            $msg = sprintf(
                'TikaRestClient was not able to process %s. Response: %s %s.',
                $file,
                $e->getResponse()->getStatusCode(),
                $e->getResponse()->getReasonPhrase()
            );
            // Only available if tika-server was started with --includeStack
            $body = $e->getResponse()->getBody();
            if ($body) {
                $msg .= ' Body: ' . $body;
            }

            Injector::inst()->get(LoggerInterface::class)->info($msg);
        }

        return (string) $text;
    }
public function tika ( $ file ) { $ text = null ; try { /** @var Response $response */ $ response = $ this -> put ( 'tika' , $ this -> getGuzzleOptions ( [ 'headers' => [ 'Accept' => 'text/plain' , ] , 'body' => file_get_contents ( $ file ) , ] ) ) ; $ text = $ response -> getBody ( ) ; } catch ( RequestException $ e ) { $ msg = sprintf ( 'TikaRestClient was not able to process %s. Response: %s %s.' , $ file , $ e -> getResponse ( ) -> getStatusCode ( ) , $ e -> getResponse ( ) -> getReasonPhrase ( ) ) ; // Only available if tika-server was started with --includeStack $ body = $ e -> getResponse ( ) -> getBody ( ) ; if ( $ body ) { $ msg .= ' Body: ' . $ body ; } Injector :: inst ( ) -> get ( LoggerInterface :: class ) -> info ( $ msg ) ; } return ( string ) $ text ; }
Extract text content from a given file.
Logs a notice-level error if the document can't be parsed.

@param  string $file Full filesystem path to a file to post
@return string Content of the file extracted as plain text
Extract text content from a given file . Logs a notice - level error if the document can t be parsed .