protected function downloadFile($file)
    {
        $dest = tempnam(sys_get_temp_dir(), 'TIKA');

        $fp = fopen($dest, 'w+');

        if($fp === false)
        {
            throw new Exception("$dest can't be opened");
        }

        $ch = curl_init($file);
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        curl_exec($ch);

        if(curl_errno($ch))
        {
            throw new Exception(curl_error($ch));
        }

        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        curl_close($ch);

        if($code != 200)
        {
            throw new Exception("$file can't be downloaded", $code);
        }

        return $dest;
    }
protected function downloadFile($file)
    {
        $dest = tempnam(sys_get_temp_dir(), 'TIKA');

        $fp = fopen($dest, 'w+');

        if($fp === false)
        {
            throw new Exception("$dest can't be opened");
        }

        $ch = curl_init($file);
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        curl_exec($ch);

        if(curl_errno($ch))
        {
            throw new Exception(curl_error($ch));
        }

        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        curl_close($ch);

        if($code != 200)
        {
            throw new Exception("$file can't be downloaded", $code);
        }

        return $dest;
    }
protected function downloadFile ( $ file ) { $ dest = tempnam ( sys_get_temp_dir ( ) , 'TIKA' ) ; $ fp = fopen ( $ dest , 'w+' ) ; if ( $ fp === false ) { throw new Exception ( "$dest can't be opened" ) ; } $ ch = curl_init ( $ file ) ; curl_setopt ( $ ch , CURLOPT_FILE , $ fp ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , 5 ) ; curl_exec ( $ ch ) ; if ( curl_errno ( $ ch ) ) { throw new Exception ( curl_error ( $ ch ) ) ; } $ code = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; curl_close ( $ ch ) ; if ( $ code != 200 ) { throw new Exception ( "$file can't be downloaded" , $ code ) ; } return $ dest ; }
Download file to a temporary folder

@link    https://wiki.apache.org/tika/TikaJAXRS#Specifying_a_URL_Instead_of_Putting_Bytes
@param   string  $file
@return  string
@throws  \Exception
Download file to a temporary folder