Add a download task with the specified file (torrent, nzb...)
@param $download_file_rdi
@param string $download_dir_rdi
@param string $archive_password
@return int
198270
public function addFromFile( $download_file_rdi, $download_dir_rdi = '', $archive_password = ''){
        $rest = $this->getService( self::API_DOWNLOAD_ADD);
        $rest->setContentType_MultipartFormData();
        $rest->POST([
            'download_file'     => new \CURLFile( $download_file_rdi),
            'download_dir'      => base64_encode( $download_dir_rdi),
            'archive_password'  => $archive_password,
        ]);

        return $rest->getResult()['id'];
    }
1291941
public function create($archive, $files)
	{
		$contents = array();
		$ctrldir = array();

		foreach ($files as $file)
		{
			$this->addToZIPFile($file, $contents, $ctrldir);
		}

		return $this->createZIPFile($contents, $ctrldir, $archive);
	}
947500
function(dataUri, fileName) {

            var blob = joint.util.dataUriToBlob(dataUri);
            joint.util.downloadBlob(blob, fileName);
        }
886398
def download(self, torrent_id, directory, filename) :
        
        return self.call('torrents/download/%s' % torrent_id, params={'filename' : filename, 'directory' : directory})
826597
function downloadTorrentFile(url, cookie, callback) {
        post({
            method: 'web.download_torrent_from_url',
            params: [url,cookie]
        }, callback);
    }
1139010
public static void downloadFile(String hostname, String username,
			String password, String remoteSource, String localDestination)
			throws Exception {
		FTPClient ftp = new FTPClient();
		ftp.connect(hostname);
		ftp.login(username, password);
		ftp.setFileType(FTP.BINARY_FILE_TYPE);
		ftp.enterLocalPassiveMode();
		FileOutputStream fos = new FileOutputStream(localDestination);
		ftp.retrieveFile(remoteSource, fos);
		ftp.logout();
		ftp.disconnect();
	}
260348
public function b2_download_file_by_id($download_url, $file_id, $auth_token = NULL)
        {
            $call_url     = $download_url."/b2api/v1/b2_download_file_by_id?fileId=".$file_id;
            $auth_token   = $auth_token; // Obtained from the b2_authorize_account call
            $download_url = $download_url; // Obtained from the b2_authorize_account call
            $file_id      = $file_id; // The ID of the file you wish to download

            // Add headers
            $headers = array(
                "Authorization: {$auth_token}"
            );

            $result = b2_call($call_url, $headers);
            return $result; // Return the result
        }
881370
public function downloadPackage() {

		if (!is_dir($this->baseFolder)) {
			$app = Application::getInstance();
			$app->enqueueError('Plugin folder is missing');
			//$app->redirect($this->type . 's/default');
		}
		
		$this->createManifestFile();
		
		// removes old archives
		static::removeOldFiles();
		
		// useful paths
		$pathInfos	= pathInfo($this->baseFolder);
		$parentPath	= $pathInfos['dirname'];
		$dirName	= $pathInfos['basename'];
		
		// creates unique file name
		$filename	= Utilities::uniqueFilename($this->name . ucfirst($this->type) . '.zip', self::TEMP_FOLDER);
		$zipFile	= self::TEMP_FOLDER . '/' . $filename;
		
		// creates the ZIP archive
		$zip = new \ZipArchive();
		$zip->open($zipFile, \ZipArchive::CREATE);
		$zip->addEmptyDir($dirName);
		
		// recursive function to add all files in all sub-folders
		self::folderToZip($this->baseFolder, $zip, $parentPath);
		
		$zip->close();
		
		// add some log
		$app = Application::getInstance();
		$app->logEvent('Created ZIP file archive ' . $zipFile . ' for ' . $this->type . ' plugin');

		// lets user download the ZIP file
		header("Content-Type: application/zip");
		header("Content-Disposition: attachment; filename=$filename");
		header("Content-Length: " . filesize($zipFile));
		
		// sends the zip as download
		readfile($zipFile);
		exit();
		
	}
550142
public function downloadzippedAction() {
        $params = $this->getRequest()->getParams();

        if (!array_key_exists('files', $params)
            || !array_key_exists('zipname', $params)
            || !$params['files']
            || !$params['zipname']
        ) {
            throw new Exception('Please provide a filename list, and a name for the archive.');
        }

        $zip = new ZipArchive();
        $tmpDir = sys_get_temp_dir();
        $tmpDir .= $tmpDir[strlen($tmpDir) - 1] !== '/' ? '/' : '';
        $zipPath = $tmpDir . $params['zipname'] . '.zip';

        if ($zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
            throw new Exception("Cannot open <$zipPath>\n");
        }

        //  @todo: als cdn niet lokaal is, moet je waarschijnlijk met zip::addFromString werken.
        $filenames = explode(',', $params['files']);

        $image = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD);
        $document = new Garp_File(null, Garp_File::FILE_VARIANT_UPLOAD);
        $ini = Zend_Registry::get('config');
        $cdnIsLocal = $ini->cdn->type === "local";

        foreach ($filenames as $filename) {
            $allowedImageExtensions = $image->getAllowedExtensions();
            $filenameParts = explode('.', $filename);
            $extension = $filenameParts[count($filenameParts) - 1];

            $fileIsImage = in_array($extension, $allowedImageExtensions);

            $file = $fileIsImage ? $image : $document;

            $url = $file->getUrl($filename);
            if ($content = @file_get_contents($url)) {
                $zip->addFromString('/' . $params['zipname'] . '/' . $filename, $content);
            } else {
                throw new Exception("{$url} could not be opened for inclusion in the zip archive.");
            }
        }

        $zip->close();

        $this->_downloadFile($zipPath);
        @unlink($zipPath);
    }
750319
def download_archive(self, archive):
        
        logger.info('Downloading archive %s', archive.id)
        r = self.session.get(self.server_url + 'downloadarquivo/{}'.format(archive.id))
        r.raise_for_status()

        # open the archive
        archive_stream = io.BytesIO(r.content)
        if is_rarfile(archive_stream):
            logger.debug('Identified rar archive')
            archive.content = RarFile(archive_stream)
        elif is_zipfile(archive_stream):
            logger.debug('Identified zip archive')
            archive.content = ZipFile(archive_stream)
        else:
            raise ValueError('Not a valid archive')
1193499
public function add($file, $entry_name = null)
    {
        // Make sure to adapt the entry name as the original filename.
        if (!isset($entry_name)) {
            $entry_name = basename($file);
        }
        $result = $this->zip->addFile($file, $entry_name);
        if ($result === false) {
            throw new ArchiveException('Error adding ' . $file);
        }

        return $this;
    }
547869
private function download($uri)
    {
        curl_setopt($this->handle, CURLOPT_URL, $uri);
        $result = curl_exec($this->handle);

        $curl_info = curl_getinfo($this->handle);
        if ($curl_info['http_code'] >= 400) {
            throw new DownloaderException(
                sprintf(
                    "Failed to download '%s'. HTTP Code: %d",
                    $uri,
                    $curl_info['http_code']
                )
            );
        }
        return $result;
    }
528711
def download_resource(self, download_url, target, guard):
        
        download_url = download_url.strip()
        if not os.path.isabs(target):
            target = os.path.join(config.config_dir, target)

        if os.path.exists(os.path.join(target, guard)):
            self.LOG.info("Already have '%s' in '%s'..." % (download_url, target))
            return

        if not os.path.isdir(target):
            os.makedirs(target)

        self.LOG.info("Downloading '%s' to '%s'..." % (download_url, target))
        with closing(urllib2.urlopen(download_url)) as url_handle:
            if download_url.endswith(".zip"):
                with closing(ZipFile(StringIO(url_handle.read()))) as zip_handle:  # pylint: disable=no-member
                    zip_handle.extractall(target)  # pylint: disable=no-member
            else:
                with open(os.path.join(target, guard), "wb") as file_handle:
                    shutil.copyfileobj(url_handle, file_handle)
1051814
public void download(String magnetUri, File saveDir) {
        if (session == null) {
            return;
        }

        error_code ec = new error_code();
        add_torrent_params p = add_torrent_params.parse_magnet_uri(magnetUri, ec);

        if (ec.value() != 0) {
            throw new IllegalArgumentException(ec.message());
        }

        sha1_hash info_hash = p.getInfo_hash();

        torrent_handle th = session.find_torrent(info_hash);

        if (th != null && th.is_valid()) {
            // found a download with the same hash
            return;
        }

        if (saveDir != null) {
            p.setSave_path(saveDir.getAbsolutePath());
        }

        torrent_flags_t flags = p.getFlags();

        flags = flags.and_(TorrentFlags.AUTO_MANAGED.inv());

        p.setFlags(flags);

        session.async_add_torrent(p);
    }
693273
public function createArchiveManager(Config $config, Downloader\DownloadManager $dm = null)
    {
        if (null === $dm) {
            $io = new IO\NullIO();
            $io->loadConfiguration($config);
            $dm = $this->createDownloadManager($io, $config);
        }

        $am = new Archiver\ArchiveManager($dm);
        $am->addArchiver(new Archiver\PharArchiver);

        return $am;
    }
926785
def download_rec(session, rec_url, target_path):
    """"""
    try:
        resp = session.get(session.auth.base_url + rec_url)
    except RequestException:
        raise VooblyError('failed to connect for download')
    try:
        downloaded = zipfile.ZipFile(io.BytesIO(resp.content))
        downloaded.extractall(target_path)
    except zipfile.BadZipFile:
        raise VooblyError('invalid zip file')
    return downloaded.namelist()[0]
396081
protected function download($zipFile, $version = 'master')
    {
        switch ($version) {
            case 'develop':
                $filename = 'latest-develop.zip';
                break;
            case 'master':
                $filename = 'latest.zip';
                break;
        }

        $response = (new Client)->get('http://cabinet.laravel.com/'.$filename);

        file_put_contents($zipFile, $response->getBody());

        return $this;
    }