Merge pull request #55 from ichaber/fix/54-clean-temp-file

#54 Cleanup temporary file
This commit is contained in:
Robbie Averill 2019-06-26 15:25:20 +12:00 committed by GitHub
commit 943f393ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -127,6 +127,11 @@ class TikaServerTextExtractor extends FileTextExtractor
public function getContent($file)
{
$tempFile = $file instanceof File ? $this->getPathFromFile($file) : $file;
return $this->getClient()->tika($tempFile);
$content = $this->getClient()->tika($tempFile);
//Cleanup temp file
if ($file instanceof File) {
unlink($tempFile);
}
return $content;
}
}

View File

@ -80,6 +80,10 @@ class TikaTextExtractor extends FileTextExtractor
$path = $file instanceof File ? $this->getPathFromFile($file) : $file;
$command = sprintf('tika %s %s', $mode, escapeshellarg($path));
$code = $this->runShell($command, $output);
//Cleanup temp file
if ($file instanceof File) {
unlink($path);
}
if ($code == 0) {
return $output;