Download Code Package

@param String $code_id.

@throws \InvalidArgumentException
@return string zipped file
493582
public function downloadCode($code_id)
    {
        if (empty($code_id)) {
            throw new \InvalidArgumentException("Please set code_id");
        }
        $url = "projects/{$this->project_id}/codes/$code_id/download";
        return $this->apiCall(self::GET, $url);
    }
384035
function downloadCode(db, codePath) {
  return mkdir(codePath)
    .then(() => db.code.loadModules())
    .then((modules) => Promise.all(modules.map(module => downloadCodeModule(db, module, codePath))));
}
1158111
public static function loadLinkInfo($link_id)
    {
        global $CFG, $PDOX, $CONTEXT;

        $cacheloc = 'lti_link';
        $row = Cache::check($cacheloc, $link_id);
        if ( $row != false ) return $row;
        $stmt = $PDOX->queryDie(
            "SELECT title FROM {$CFG->dbprefix}lti_link
                WHERE link_id = :LID AND context_id = :CID",
            array(":LID" => $link_id, ":CID" => $CONTEXT->id)
        );
        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
        Cache::set($cacheloc, $link_id, $row);
        return $row;
    }
14476
public static function download( $id, $repository_name ) {
		if ( Utils\is_snapshot_cached( $id ) ) {
			Log::instance()->write( 'Snapshot found in cache.' );

			return self::get( $id );
		}

		$create_dir = Utils\create_snapshot_directory( $id );

		if ( ! $create_dir ) {
			Log::instance()->write( 'Cannot create necessary snapshot directories.', 0, 'error' );

			return false;
		}

		$repository = RepositoryManager::instance()->setup( $repository_name );

		if ( ! $repository ) {
			Log::instance()->write( 'Could not setup repository.', 0, 'error' );

			return false;
		}

		Log::instance()->write( 'Getting snapshot information...' );

		$snapshot = $repository->getDB()->getSnapshot( $id );

		if ( ! $snapshot ) {
			Log::instance()->write( 'Could not get snapshot from database.', 0, 'error' );

			return false;
		}

		if ( empty( $snapshot ) || empty( $snapshot['project'] ) ) {
			Log::instance()->write( 'Missing critical snapshot data.', 0, 'error' );
			return false;
		}

		/**
		 * Backwards compant. Add repository to meta before we started saving it.
		 */
		if ( empty( $snapshot['repository'] ) ) {
			$snapshot['repository'] = $repository_name;
		}

		Log::instance()->write( 'Downloading snapshot files and database (' . Utils\format_bytes( $snapshot['size'] ) . ')...' );

		$snapshot_path = Utils\get_snapshot_directory() . $id . '/';

		$download = $repository->getS3()->downloadSnapshot( $id, $snapshot['project'], $snapshot_path . 'data.sql.gz', $snapshot_path . 'files.tar.gz' );

		if ( ! $download ) {
			Log::instance()->write( 'Failed to download snapshot.', 0, 'error' );

			return false;
		}

		/**
		 * Finally save snapshot meta to meta.json
		 */
		$meta_handle = @fopen( $snapshot_path . 'meta.json', 'x' ); // Create file and fail if it exists.

		if ( ! $meta_handle ) {
			Log::instance()->write( 'Could not create meta.json.', 0, 'error' );

			return false;
		}

		fwrite( $meta_handle, json_encode( $snapshot, JSON_PRETTY_PRINT ) );

		return new self( $id, $repository_name, $snapshot, true );
	}
629667
public function downloadLogCollectorContentZip($id)
    {
        $url = self::makeUrl($id, true);
        $response = $this->service->prepAndSend($url, array(200), "GET", null, true, "application/json", "application/zip");

        return $response;
    }
863693
def download(self, resource_id):
        
        self.resource_id(str(resource_id))
        self._request_uri = '{}/download'.format(self._request_uri)
699718
public function consume($code, $card_id = null)
    {
        $data = ['code' => $code];
        is_null($card_id) || $data['card_id'] = $card_id;
        $url = "https://api.weixin.qq.com/card/code/consume?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
96373
public function getLogFromId( $download_id){
        $logService = sprintf( self::API_DOWNLOAD_LOG, $download_id);
        $rest = $this->getService( $logService);
        $rest->GET();

        return $rest->getResult();
    }
336574
public function downloadAction()
    {
        $model = $this->getModel();
        $model->applyRequest($this->getRequest());

        $fileData = $model->loadFirst();

        header('Content-Type: application/x-download');
        header('Content-Length: '.$fileData['size']);
        header('Content-Disposition: inline; filename="'.$fileData['filename'].'"');
        header('Pragma: public');

        echo $fileData['content'];
        exit();
    }
142843
public function download_menu()
    {
        $this->include_script('zipdownload.js');
        $this->add_label('download');

        $rcmail  = rcmail::get_instance();
        $menu    = array();
        $ul_attr = array('role' => 'menu', 'aria-labelledby' => 'aria-label-zipdownloadmenu');
        if ($rcmail->config->get('skin') != 'classic') {
            $ul_attr['class'] = 'toolbarmenu';
        }

        foreach (array('eml', 'mbox', 'maildir') as $type) {
            $menu[] = html::tag('li', null, $rcmail->output->button(array(
                    'command'  => "download-$type",
                    'label'    => "zipdownload.download$type",
                    'classact' => 'active',
            )));
        }

        $rcmail->output->add_footer(html::div(array('id' => 'zipdownload-menu', 'class' => 'popupmenu', 'aria-hidden' => 'true'),
            html::tag('h2', array('class' => 'voice', 'id' => 'aria-label-zipdownloadmenu'), "Message Download Options Menu") .
            html::tag('ul', $ul_attr, implode('', $menu))));
    }
713755
public static function unZip($zip_file, $destination)
    {
        $zip = new \ZipArchive();
        $archive = $zip->open($zip_file);

        if ($archive === true) {
            Folder::create($destination);

            $unzip = $zip->extractTo($destination);


            if (!$unzip) {
                self::$error = self::ZIP_EXTRACT_ERROR;
                Folder::delete($destination);
                $zip->close();
                return false;
            }

            $package_folder_name = preg_replace('#\./$#', '', $zip->getNameIndex(0));
            $zip->close();

            return $destination . '/' . $package_folder_name;
        }

        self::$error = self::ZIP_EXTRACT_ERROR;
        self::$error_zip = $archive;
        return false;
    }
750935
function Invalid(message, code_id) {
    Error.call(this);
    this.message = message || "invalid";
    this.code_id = code_id || null;
    this.statusCode = 403;
}
925155
public function getElement($file_id)
    {
        $ret = ['success' => false, 'message' => '', 'result'  => []];
        
        /* @var LazaretFile $lazaretFile */
        $lazaretFile = $this->getLazaretFileRepository()->find($file_id);

        if (null === $lazaretFile) {
            $ret['message'] = $this->app->trans('File is not present in quarantine anymore, please refresh');

            return $this->app->json($ret);
        }

        $ret['result'] = [
            'filename' => $lazaretFile->getOriginalName(),
            'base_id'  => $lazaretFile->getBaseId(),
            'created'  => $lazaretFile->getCreated()->format(\DateTime::ATOM),
            'updated'  => $lazaretFile->getUpdated()->format(\DateTime::ATOM),
            'pathname' => $this->app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename(),
            'sha256'   => $lazaretFile->getSha256(),
            'uuid'     => $lazaretFile->getUuid(),
        ];
        $ret['success'] = true;

        return $this->app->json($ret);
    }
1034347
public function CreateEncrpytionKey()
	{
		if (function_exists('random_bytes'))
		{
			return base64_encode(random_bytes(32));
		}
		if (function_exists('openssl_random_pseudo_bytes'))
		{
			return base64_encode(openssl_random_pseudo_bytes(32));
		}
		throw new GrabzItException("Your installation of PHP does not support a method for making a cryptographically secure encryption key. Please upgrade to at least PHP 5.3", GrabzItException::GENERIC_ERROR);		
	}
788891
public function getRegistrationLink($program_id, $session_id) {
    $uri = $this->getUrlFromOpenyProgramsSearchSettings('registration_path');

    $query = [
      'program_id' => $program_id,
      'session_ids' => $session_id,
    ];

    $path = Url::fromUri(
      $uri,
      [
        'query' => $query,
        'absolute' => TRUE,
        'https' => TRUE,
      ]
    );

    return $path->toString();
  }
687044
protected function scrapeDaxkoSchoolsByProgram($program_id) {
    $link = $this->getUrlFromOpenyProgramsSearchSettings('get_schools_by_program_path', ['{{ program_id }}' => $program_id]);
    $source = $this->getDaxkoPageSource($link);

    $this->crawler->clear();
    $this->crawler->addHtmlContent($source);
    return $this->crawler->filter('div.two-column-container ul li a');
  }
886398
def download(self, torrent_id, directory, filename) :
        
        return self.call('torrents/download/%s' % torrent_id, params={'filename' : filename, 'directory' : directory})