Download the exported file

@return mixed
977682
public function actionDownload() {
        /**
         * @var Module $module
         */
        $module = Config::initModule(Module::className());
        $request = Yii::$app->request;
        $type = $request->post('export_filetype', 'html');
        $name = $request->post('export_filename', Yii::t('kvgrid', 'export'));
        $content = $request->post('export_content', Yii::t('kvgrid', 'No data found'));
        $mime = $request->post('export_mime', 'text/plain');
        $encoding = $request->post('export_encoding', 'utf-8');
        $bom = $request->post('export_bom', 1);
        $config = $request->post('export_config', '{}');
        $oldHash = $request->post('export_hash');
        $newData = $name . $mime . $encoding . $bom . $config;
        $security = Yii::$app->security;
        $salt = $module->exportEncryptSalt;
        $newHash = $security->hashData($newData, $salt);
        if (!$security->validateData($oldHash, $salt) || $oldHash !== $newHash) {
            $params = "\nOld Hash:{$oldHash}\nNew Hash:{$newHash}\n";
            throw new InvalidCallException("The parameters for yii2-grid export seem to be tampered. Please retry!{$params}");
        }
        if ($type == GridView::PDF) {
            $config = Json::decode($config);
            $this->generatePDF($content, "{$name}.pdf", $config);
            /** @noinspection PhpInconsistentReturnPointsInspection */
            return;
        } elseif ($type == GridView::HTML) {
            $content = HtmlPurifier::process($content);
        } elseif ($type == GridView::CSV || $type == GridView::TEXT) {
            if ($encoding != 'utf-8') {
                $content = mb_convert_encoding($content, $encoding, 'utf-8');
            } elseif ($bom) {
                $content = chr(239) . chr(187) . chr(191) . $content; // add BOM
            }
        }

        $this->setHttpHeaders($type, $name, $mime, $encoding);
        return $content;
    }
108848
public function downloadAction()
	{
		$paths = Base::getAimeos()->getCustomPaths( 'client/html' );
		$context = $this->getContext();
		$view = $context->getView();

		$client = \Aimeos\Client\Html::create( $context, 'account/download' );
		$client->setView( $view );
		$client->process();

		$response = $view->response();
		$this->response->setStatus( $response->getStatusCode() );

		foreach( $response->getHeaders() as $key => $value ) {
			$this->response->setHeader( $key, implode( ', ', $value ) );
		}

		return (string) $response->getBody();
	}
752058
public function DownloadLink() {
		// get the base URL, prepend with the external content
		// controller /download action and add this object's id
		$cur = Controller::curr();
		if ($cur instanceof ExternalContentPage_Controller) {
			return $cur->data()->LinkFor($this, 'download');
		}
		return ExternalContentPage_Controller::URL_STUB . '/download/' . $this->ID;
	}
492039
public function download()
    {
        foreach ($this->children as $child) {
            if ($child instanceof DownloadableClientInterface) {
                return $child->download();
            }
        }

        throw MissingDownloadableClientsException::create();
    }
1104733
private function downloadContent()
    {
        $params = [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_URL => $this->url,
        ];
        if (false === $this->allow_unsecured_connection) {
            $params[CURLOPT_SSL_VERIFYPEER] = true;
            $params[CURLOPT_SSL_VERIFYHOST] = 2;
        }

        $ch = curl_init();
        curl_setopt_array($ch, $params);
        if (!empty($this->custom_headers)) {
            curl_setopt($ch, CURLOPT_HTTPHEADER, $this->custom_headers);
        }
        $content = curl_exec($ch);

        try {
            Assertion::false(false === $content, 'Failed to load JWK contents: ');
        } catch (\Assert\AssertionFailedException $e) {
            $curlError = curl_error($ch);
            $curlErrorNumber = curl_errno($ch);

            throw new \InvalidArgumentException(
                $e->getMessage().$curlError,
                $curlErrorNumber
            );
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(
                'Failed to load JWK contents: '.$e->getMessage(),
                0
            );
        } finally {
            curl_close($ch);
        }

        return $content;
    }
1265691
public function export()
	{
		$systemPaths = explode(PATH_SEPARATOR, get_include_path());
		set_include_path(implode(PATH_SEPARATOR,
			array_merge($systemPaths,$this->_paths)));
		return $this;
	}
476972
public function doExport()
    {
        $this->downloadCsvExport();

        $settings = $this->module->getSettings('export');

        if (empty($settings['columns'])) {
            $settings['columns'] = array_keys($settings['header']);
        }

        $this->setData('settings', $settings);
        $this->setData('columns', $settings['header']);
        $this->setData('stores', $this->store->getList());

        $this->submitExport();
        $this->setTitleDoExport();
        $this->setBreadcrumbDoExport();

        $this->outputDoExport();
    }
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();
    }
221800
public function downloadUrl(): string
    {
        return route('media-download', [
            'xref'    => $this->media->xref(),
            'ged'     => $this->media->tree()->name(),
            'fact_id' => $this->fact_id,
        ]);
    }
862374
public function download()
    {
        $oUtils = \OxidEsales\Eshop\Core\Registry::getUtils();
        $sFileName = $this->_getFilenameForUrl();
        $sFileLocations = $this->getStoreLocation();

        if (!$this->exist() || !$this->isUnderDownloadFolder()) {
            throw new \OxidEsales\Eshop\Core\Exception\StandardException('EXCEPTION_NOFILE');
        }

        $oUtils->setHeader("Pragma: public");
        $oUtils->setHeader("Expires: 0");
        $oUtils->setHeader("Cache-Control: must-revalidate, post-check=0, pre-check=0, private");
        $oUtils->setHeader('Content-Disposition: attachment;filename=' . $sFileName);
        $oUtils->setHeader("Content-Type: application/octet-stream");
        if ($iFileSize = $this->getSize()) {
            $oUtils->setHeader("Content-Length: " . $iFileSize);
        }
        readfile($sFileLocations);
        $oUtils->showMessageAndExit(null);
    }
743463
public function export()
    {
        // Check if value is cached and set array to cached version
        if (Cache::has(config('laravel-localization.caches.key'))) {
            $this->strings = Cache::get(config('laravel-localization.caches.key'));

            return $this;
        }

        foreach (config('laravel-localization.paths.lang_dirs') as $dir) {
            try {

                // Collect language files and build array with translations
                $files = $this->findLanguageFiles($dir);

                // Parse translations and create final array
                array_walk($files['lang'], [$this, 'parseLangFiles'], $dir);
                array_walk($files['vendor'], [$this, 'parseVendorFiles'], $dir);
                array_walk($files['json'], [$this, 'parseJsonFiles'], $dir);
            } catch (\Exception $exception) {
                \Log::critical('Can\'t read lang directory '.$dir.', error: '.$exception->getMessage());
            }
        }

        // Trigger event for final translated array
        event(new LaravelLocalizationExported($this->strings));

        // If timeout > 0 save array to cache
        if (config('laravel-localization.caches.timeout', 0) > 0) {
            Cache::store(config('laravel-localization.caches.driver', 'file'))
                 ->put(
                     config('laravel-localization.caches.key', 'localization.array'),
                     $this->strings,
                     config('laravel-localization.caches.timeout', 60)
                 );
        }

        return $this;
    }
423897
protected function downloadFile()
    {
        $file_id = $this->getQuery('download');

        if (!empty($file_id)) {
            $file = $this->file->get($file_id);
            $this->download(gplcart_file_absolute($file['path']));
        }
    }
610932
protected function downloadExportFile()
    {
        $this->view->layout()->disableLayout();
        \Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender(true);

        $batch          = $this->getExportBatch(false);
        $downloadName  = $batch->getSessionVariable('downloadname');
        $localFilename = $batch->getSessionVariable('filename');

        header("Content-Type: application/download");
        header("Content-Disposition: attachment; filename=\"$downloadName\"");
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Pragma: cache");                          // HTTP/1.0
        readfile($localFilename);
        exit();
    }
694667
public function downloadData()
	{
		// Download file, or handle error
		$data = $this->wikimate->download($this->getUrl());
		if ($data === null) {
			$this->error = $this->wikimate->getError(); // Copy error if there was one
		} else {
			$this->error = null; // Reset the error status
		}

		return $data;
	}
1002431
protected function export()
    {
        $filesystem = new Filesystem();
        $handle = fopen($this->config['path'] . $this->prefix, "w");

        $checkPermissions = true;
        if (PHP_SAPI == 'cli') {
            $checkPermissions = false;
        }

        if (!$this->export->Init(
            $handle,
            $this->config["id"],
            false,
            true,
            $this->session["work_dir"],
            $this->session["file_dir"],
            $checkPermissions
        )
        ) {
            throw new ExportException('Failed to initialize export');
        }

        $this->export->DoNotDownloadCloudFiles();
        $this->export->StartExport();

        $this->export->StartExportMetadata();
        $this->export->ExportProperties($this->session["property_map"]);
        $this->export->ExportSections(
            $this->session["section_map"],
            time(),
            $this->config['interval'],
            $this->config["sections"],
            $this->session["property_map"]
        );
        $this->export->EndExportMetadata();

        $this->export->StartExportCatalog();
        $this->export->ExportElements(
            $this->session["property_map"],
            $this->session["section_map"],
            time(),
            $this->config['interval'],
            0,
            $this->config["elements"]
        );
        $this->export->EndExportCatalog();

        $this->export->ExportProductSets();
        $this->export->EndExport();

        fclose($handle);
        $filesystem->remove($this->config['path']);
        $filesystem->rename($this->config['path'] . $this->prefix, $this->config['path'], true);
    }
85714
private function getZip()
    {
        $this->info("Downloading");

        $sourceContent = file_get_contents($this->argument('source'));
        if(!$sourceContent) {
            throw new \Exception('Source could not be found!');
        }

        $this->tmpRandomName = time();
        $this->tmpZipFile = tmpPath($this->tmpRandomName.'.zip');

        // Save zip to tmp directory
        if(!file_put_contents($this->tmpZipFile, $sourceContent)) {
            File::delete($this->tmpZipFile);
            throw new \Exception('Could not copy source file to path '.$this->tmpZipFile);
        }

        return $this;
    }
934090
public function download()
    {
        $driveLocator = "/drives/{$this->parentReference->driveId}";
        $itemLocator  = "/items/{$this->id}";
        $endpoint     = "$driveLocator$itemLocator/content";

        $response = $this
            ->graph
            ->createRequest('GET', $endpoint)
            ->execute();

        $status = $response->getStatus();

        if ($status != 200) {
            throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status");
        }

        return $response->getResponseAsObject(Stream::class);
    }