Download

@access public
@param  $url
@param  $mixed_filename

@return boolean
485422
public function download($url, $mixed_filename)
    {
        if (is_callable($mixed_filename)) {
            $this->downloadCompleteFunction = $mixed_filename;
            $this->fileHandle = tmpfile();
        } else {
            $filename = $mixed_filename;

            // Use a temporary file when downloading. Not using a temporary file can cause an error when an existing
            // file has already fully completed downloading and a new download is started with the same destination save
            // path. The download request will include header "Range: bytes=$filesize-" which is syntactically valid,
            // but unsatisfiable.
            $download_filename = $filename . '.pccdownload';

            $mode = 'wb';
            // Attempt to resume download only when a temporary download file exists and is not empty.
            if (file_exists($download_filename) && $filesize = filesize($download_filename)) {
                $mode = 'ab';
                $first_byte_position = $filesize;
                $range = $first_byte_position . '-';
                $this->setOpt(CURLOPT_RANGE, $range);
            }
            $this->fileHandle = fopen($download_filename, $mode);

            // Move the downloaded temporary file to the destination save path.
            $this->downloadCompleteFunction = function ($fh) use ($download_filename, $filename) {
                rename($download_filename, $filename);
            };
        }

        $this->setOpt(CURLOPT_FILE, $this->fileHandle);
        $this->get($url);

        return ! $this->error;
    }
42194
public function load(string $url): bool
    {
        $this->parsedfile = (new Parser($url))->get();

        return $this->preValidate();
    }
1364476
public Response download(String url, File destination) throws IOException {
		return download(url, destination, (String[]) null);
	}
1084738
private function _downloadFile($url, $filename)
    {
        $dirname = dirname($filename);
        if (! is_dir($dirname)) {
            mkdir($dirname, 0777, true);
        }
        saveUrl($url, $filename);
    }
1226999
def download_file(url, file_path, mkdir=False):
    
    folder, fname = os.path.split(file_path)
    return download_file_by_name(url, folder, fname, mkdir)
880875
public function downloadFile(string $fileName)
    {
        return $this->file(rawurldecode($fileName), null, ResponseHeaderBag::DISPOSITION_INLINE);
    }
356767
function download( $url, $local, $headers = array(), $verifyssl = null ) {
		global $argv;

		$out = fopen( $local, 'wb' );

		if( is_string( $headers ) ) curl_setopt( $this->curl_instance, CURLOPT_HTTPHEADER, array( $headers ) );
		else $this->setCurlHeaders( $headers );
		$this->setVerifySSL( $verifyssl );

		// curl_setopt($this->curl_instance, CURLOPT_FILE, $out);
		curl_setopt( $this->curl_instance, CURLOPT_HTTPGET, 1 );
		curl_setopt( $this->curl_instance, CURLOPT_POST, 0 );
		curl_setopt( $this->curl_instance, CURLOPT_URL, $url );
		curl_setopt( $this->curl_instance, CURLOPT_HEADER, 0 );

		if( ( !is_null( $argv ) && in_array( 'peachyecho', $argv ) ) || $this->echo ) {
			pecho( "DLOAD: $url\n", PECHO_NORMAL );
		}

		Hooks::runHook( 'HTTPDownload', array( &$this, &$url, &$local ) );

		fwrite( $out, $this->doCurlExecWithRetrys() );
		fclose( $out );

		return true;

	}
1280018
public function download($filename)
    {
        return $this->response->withFile($this->getPath($filename, false), ['download' => true]);
    }
691691
public function downloadAction($filename)
    {
        $pathname = $this->getArchiver()->buildPathname($filename);

        if (!is_readable($pathname)) {
            throw $this->createNotFoundException(sprintf('Image archive "%s" is not readable.', $pathname));
        }

        return new BinaryFileResponse($pathname);
    }
299226
def download(url, filename, overwrite = False):
	'''  '''

	from requests import get
	from os.path import exists

	debug('Downloading ' + unicode(url) + '...')
	data = get(url)
	if data.status_code == 200:
		if not exists(filename) or overwrite:
			f = open(filename, 'wb')
			f.write(data.content)
			f.close()
		return True
	return False
439879
protected function _fetchRemoteFile($url)
  {
    // try to fetch the file
    if ($this->_use_curl) {
      $connection = $this->_getCurlInitialization($url);
      $this->_curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
      $this->_curl_setopt($connection, CURLOPT_HEADER, 0);
      // no SSL validation for downloading media
      $this->_curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 1);
      $this->_curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 2);
      $this->_curl_setopt($connection, CURLOPT_TIMEOUT_MS, $this->_timeouts['remote']);
      $this->_curl_setopt($connection, CURLOPT_CONNECTTIMEOUT_MS, $this->_timeouts['remote'] / 2);
      // find files that have been redirected
      $this->_curl_setopt($connection, CURLOPT_FOLLOWLOCATION, true);
      // process compressed images
      $this->_curl_setopt($connection, CURLOPT_ENCODING, 'gzip,deflate,sdch');
      $result = $this->_curl_exec($connection);
      if ($result !== false
        && $this->_curl_getinfo($connection, CURLINFO_HTTP_CODE) === 200
      ) {
        return $result;
      }
      throw new CodebirdMediaException('Downloading a remote media file failed.');
      return false;
    }
    // no cURL
    $contextOptions = [
      'http' => [
        'method'           => 'GET',
        'protocol_version' => '1.1',
        'timeout'          => $this->_timeouts['remote']
      ],
      'ssl' => [
        'verify_peer'  => false
      ]
    ];
    list($result, $headers) = $this->_getNoCurlInitialization($url, $contextOptions);
    if ($result !== false
      && preg_match('/^HTTP\/\d\.\d 200 OK$/', $headers[0])
    ) {
      return $result;
    }
    throw new CodebirdMediaException('Downloading a remote media file failed.');
    return false;
  }
247949
public function download($filename = '')
    {
        $filename = $this->formatFilename($filename);
        if ($this->content) {
            $this->printHeader();
            header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
            ob_clean();
            echo $this->content;
        } elseif ($this->path) {
            $fsize = filesize($this->path);
            $this->printHeader($fsize);
            header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
            ob_clean();
            readfile($this->path);
        }
    }
991752
static function downloadToTempfile($url) {
        $download_path = Files::getTempFilename();
        $fp = fopen($download_path, 'w+');
        fwrite($fp, file_get_contents($url));
        fclose($fp);
        return $download_path;
    }
1144391
public function makeFromUrl($url, $name = null, $mimeType = null)
    {
        try {
            $localPath = $this->downloader->download($url);

        } catch (Exception $e) {

            throw new CouldNotRetrieveRemoteFileException(
                "Could not retrieve file from '{$url}'",
                $e->getcode(),
                $e
            );
        }

        if (null === $name) {
            $name = $this->getBaseNameFromUrl($url);
        }

        // Always flag as uploaded, since we downloaded to a local path
        return $this->uploaded()->makeFromLocalPath($localPath, $name, $mimeType);
    }
1163237
function download($file_pointer) {
    if (empty($this->download_url)) {
      $this->_save(Recurly_Client::GET, $this->getHref());
    }
    $this->_client->getFile($this->download_url, $file_pointer);
  }
402631
private function downloadTemporaryFile($url, $target)
    {
        try {
            if (($fh = @fopen($target, 'w')) === false) {
                throw new RuntimeException(
                    sprintf(
                        'Could not create file "%s": %s',
                        $target,
                        @error_get_last()['message']
                    )
                );
            }

            if ((@fwrite($fh, $this->httpClient->get($url, 'application/octet-stream'))) === false) {
                throw new RuntimeException(
                    sprintf(
                        'The "%s" file could not be downloaded: %s',
                        $url,
                        @error_get_last()['message']
                    )
                );
            }
        } finally {
            if (is_resource($fh)) {
                fclose($fh);
            }
        }
    }
42687
public function download($url, $handler, $path = null)
    {
        $result = $this->transferred = null;
        $this->hook->attach('file.download.before', $url, $handler, $path, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $this->setHandler($handler);
        $this->setDestination($path);

        try {
            $temp = $this->downloadTempFile($url);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }

        try {
            $this->validateHandler($temp);
        } catch (Exception $ex) {
            unlink($temp);
            return $ex->getMessage();
        }

        try {
            $result = $this->finalize($temp, $this->destination, false);
        } catch (Exception $ex) {
            $result = $ex->getMessage();
        }

        $this->hook->attach('file.download.after', $url, $handler, $temp, $result, $this);
        return $result;
    }