/** * Takes a file reference and detects its content's language. * * @param \TYPO3\CMS\Core\Resource\FileInterface $file * @return string Language ISO code */ public function detectLanguageFromFile(FileInterface $file) { $headers = array(TYPO3_user_agent, 'Content-Type: application/octet-stream', 'Connection: close'); $context = stream_context_create(array('http' => array('protocol_version' => 1.1, 'method' => 'PUT', 'header' => implode(CRLF, $headers), 'content' => $file->getContents()))); $response = $this->queryTika('/language/stream', $context); return $response; }