7 namespace Fossology\Lib\Util;
9 use Symfony\Component\HttpFoundation\Response;
22 if (empty($referer)) {
23 $referer =
"?mod=browse";
27 if (confirm("Do you want to download the file ' . $fileName .
'?")) {
28 fetch("' . $downloadUrl .
'")
29 .then(response => response.blob())
31 const url = window.URL.createObjectURL(blob);
32 const a = document.createElement("a");
34 a.download = "' . $fileName .
'";
35 document.body.appendChild(a);
37 window.URL.revokeObjectURL(url);
38 document.body.removeChild(a);
39 window.location.href = "' . $referer .
'";
42 window.location.href = "' . $referer .
'";
46 return new Response($script, Response::HTTP_OK, [
'Content-Type' =>
'text/html']);
59 'Content-type' => $contentType .
', charset=UTF-8',
60 'Content-Disposition' =>
'attachment; filename=' . $fileName,
61 'Pragma' =>
'no-cache',
62 'Cache-Control' =>
'no-cache, must-revalidate, maxage=1, post-check=0, pre-check=0',
63 'Expires' =>
'Expires: Thu, 19 Nov 1981 08:52:00 GMT'
66 return new Response($content, Response::HTTP_OK, $headers);
static getDownloadConfirmationResponse($downloadUrl, $fileName, $referer)
static getDownloadResponse($content, $fileName, $contentType='text/csv')