protected function SearchApiAttachmentsAlterSettings::extractTikaServer in Search API attachments 7
Extracts file content using a tika server.
Parameters
object $file: The file.
Return value
string The file content.
1 call to SearchApiAttachmentsAlterSettings::extractTikaServer()
- SearchApiAttachmentsAlterSettings::getFileContent in includes/
callback_attachments_settings.inc - Extracts th file content.
File
- includes/
callback_attachments_settings.inc, line 437 - Search API data alteration callback.
Class
- SearchApiAttachmentsAlterSettings
- Indexes files content.
Code
protected function extractTikaServer($file) {
$filepath = $this
->getRealpath($file);
$url = 'http://' . variable_get('search_api_attachments_tika_server_host', '') . ':' . variable_get('search_api_attachments_tika_server_port', 9998) . '/tika';
// Server tika.
$ch = curl_init($url);
// Request will be a PUT.
curl_setopt($ch, CURLOPT_PUT, 1);
// Set the file to send.
$file_path_str = $filepath;
$fh_res = fopen($file_path_str, 'r');
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file_path_str));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Send the request.
$curl_response_res = curl_exec($ch);
fclose($fh_res);
return $curl_response_res;
}