Provide file as download.

@param string $encFileName
@param string $encRealFileName

@return Downlaod
492606
public function asDownload($encFileName, $encRealFileName)
    {
        try {
            return Cache::remember($encFileName.'_asDownload', 3600, function () use ($encFileName, $encRealFileName) {
                $fileName = CryptoServiceFacade::url_decode($encFileName);
                $realFileName = CryptoServiceFacade::url_decode($encRealFileName);
                $filePath = $this->getFilePath($fileName);

                $fileTool = new SplFileInfo($filePath);
                $ext = $fileTool->getExtension();
                $contentType = $this->getMimeType($ext);

                $headers = ['Content-Type' => $contentType];
                $fileContent = $this->getFileContent($realFileName, $contentType, $ext);

                return Response::make($fileContent, 200, [
                    'Content-Type' => $contentType,
                    'Content-Disposition' => 'attachment; filename="'.$fileName.'"',
                ]);
            });
        } catch (Exception $e) {
            Cms::notification('We encountered an error with that file', 'danger');

            return redirect('errors/general');
        }
    }
1142713
public function download($path, $name = null)
    {
        $fResponse = new FileResponse($path);
        return $fResponse->forceDownload($name);
    }
492039
public function download()
    {
        foreach ($this->children as $child) {
            if ($child instanceof DownloadableClientInterface) {
                return $child->download();
            }
        }

        throw MissingDownloadableClientsException::create();
    }
375102
public function asPreview($encFileName, Filesystem $fileSystem)
    {
        try {
            return Cache::remember($encFileName.'_preview', 3600, function () use ($encFileName, $fileSystem) {
                $fileName = CryptoServiceFacade::url_decode($encFileName);

                if (config('cms.storage-location') === 'local' || config('cms.storage-location') === null) {
                    $filePath = storage_path('app/'.$fileName);
                    $contentType = $fileSystem->mimeType($filePath);
                    $ext = strtoupper($fileSystem->extension($filePath));
                } else {
                    $filePath = Storage::disk(config('cms.storage-location', 'local'))->url($fileName);
                    $fileTool = new SplFileInfo($filePath);
                    $ext = $fileTool->getExtension();
                    $contentType = $this->getMimeType($ext);
                }

                if (stristr($contentType, 'image')) {
                    $headers = ['Content-Type' => $contentType];
                    $fileContent = $this->getFileContent($fileName, $contentType, $ext);
                } else {
                    $fileContent = file_get_contents($this->generateImage($ext));
                }

                return Response::make($fileContent, 200, [
                    'Content-Type' => $contentType,
                    'Content-Disposition' => 'attachment; filename="'.$fileName.'"',
                ]);
            });
        } catch (Exception $e) {
            return Response::make('file not found');
        }
    }
113855
public function downloadFile($fileName, $contentType, $file)
    {
        $body = $this->builder->messages()->stream($file);
        return $this->downloadResponse($fileName, $contentType, $body);
    }
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);
    }
878655
public function download(Request $request, $name = 'output')
    {
        $pdf = PDF::loadView('laralum_pdf::pdf', ['text' => $request->text]);

        return $pdf->download("$name.pdf");
    }
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']));
        }
    }
1247502
private function callDelCreaServer(string $env)
    {
        Server::delete(FEnvFcm::get("framework.cache").$env, 'directory');
        Server::create(FEnvFcm::get("framework.cache").$env, 'directory');
    }
1296147
static function downloadRemoteFile($url, $destinationFilename) {
		if (!ini_get('allow_url_fopen')) {
			throw new \Exception('allow_url_fopen is disable', 501);
		}

        $message = "File was not loaded";

		if (function_exists('curl_init')) {
		    try {
                $raw = file_get_contents($url);
            } catch (\Exception $e) {
                throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
            }
		} else {
			$ch = curl_init($url);

			curl_setopt($ch, CURLOPT_HEADER, 0);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);// таймаут4

			$response = parse_url($url);
			curl_setopt($ch, CURLOPT_REFERER, $response['scheme'] . '://' . $response['host']);
			curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) ' .
                'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 YaBrowser/19.1.1.907 Yowser/2.5 Safari/537.36');


			$raw = curl_exec($ch);

            if (!$raw) {
                throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
            }

            curl_close($ch);
        }

        if ($raw) {
            file_put_contents($destinationFilename, $raw);
        } else {
			throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
		}
	}
842584
public function download($filename) {
    if(!empty($this->pdf->getError())) {
      throw new Exception('Could not create PDF: ' . $this->pdf->getError());
    } else {
      $filename = rtrim(File::create()->setName($filename), '.pdf') . '.pdf';
      $this->pdf->send($filename);
    }
  }
284530
public static function create(string $content, string $asName, string $contentType = null): ContentDownload
    {
        $self = new static($content);
        $self->setAsName($asName);

        if ($contentType !== null) {
            $self->setContentType($contentType);
        }

        return $self;
    }
1164340
public function downloadIfRemote($file, $ext = '', $path = '', $customName = '')
    {
        $host = parse_url($file, PHP_URL_HOST);
        if ($host) {
            $file = $this->download($file, $ext, $path, $customName);
        }

        return $file;
    }
1188278
public function asset($encPath, $contentType, Filesystem $fileSystem)
    {
        try {
            $path = CryptoServiceFacade::url_decode($encPath);

            if (Request::get('isModule') === 'true') {
                $filePath = $path;
            } else {
                if (str_contains($path, 'dist/') || str_contains($path, 'themes/')) {
                    $filePath = __DIR__.'/../Assets/'.$path;
                } else {
                    $filePath = __DIR__.'/../Assets/src/'.$path;
                }
            }

            $fileName = basename($filePath);

            if (!is_null($contentType)) {
                $contentType = CryptoServiceFacade::url_decode($contentType);
            } else {
                $contentType = $fileSystem->mimeType($fileName);
            }

            $headers = ['Content-Type' => $contentType];

            return response()->download($filePath, $fileName, $headers);
        } catch (Exception $e) {
            return Response::make('file not found');
        }
    }
201137
protected function downloadResponse($file, $name = null, array $headers = array())
	{
		$response = new BinaryFileResponse($file, 200, $headers, true, 'attachment');

		if ($name !== null) {
			return $response->setContentDisposition('attachment', $name, Str::ascii($name));
		}

		return $response;
	}
444808
public File download(String pathToFile, String extension) {
        return fileDownloadRequest.download(pathToFile, extension);
    }
277010
public function downloadFile($key, $downloadDir)
    {
        $targetPath = $downloadDir . DIRECTORY_SEPARATOR . $key;
        $path = $this->computePath($key);
        $this->fileSystem->copy($path, $targetPath);

        return $targetPath;
    }