protected function downloadTempFile($url)
    {
        $temp = $this->file->getTempFile();

        $fh = fopen($temp, "w");

        if (!is_resource($fh)) {
            throw new UnexpectedValueException($this->translation->text('File handle is not a valid resource'));
        }

        $response = $this->http->request($url);
        fwrite($fh, $response['data']);
        fclose($fh);

        return $temp;
    }