You could pull down the content of the original file, work out its mime type and then craft your own response giving the right headers.
I do this myself using a PDF library, but you could modify to use file_get_contents()
to pull down the remote assets:
return Response::make(
$pdf,
200,
array(
'Content-Description' => 'File Transfer',
'Cache-Control' => 'public, must-revalidate, max-age=0, no-transform',
'Pragma' => 'public',
'Expires' => 'Sat, 26 Jul 1997 05:00:00 GMT',
'Last-Modified' => ''.gmdate('D, d M Y H:i:s').' GMT',
'Content-Type' => 'application/pdf', false,
'Content-Disposition' => ' attachment; filename="chart.pdf";',
'Content-Transfer-Encoding' => ' binary',
'Content-Length' => ' '.strlen($pdf),
'Access-Control-Allow-Origin' => $origin,
'Access-Control-Allow-Methods' =>'GET, PUT, POST, DELETE, HEAD, PATCH',
'Access-Control-Allow-Headers' =>'accept, origin, content-type',
'Access-Control-Allow-Credentials' => 'true')
);
You need to change $pdf
to be the data of the file, Content-Type
to contain the mimetype of the file that the data is and Content-Disposition
is the filename you want it to appear as.
Not sure whether this will work, mine simply makes the browser popup with a PDF download so I'm not sure whether it'll work for embedding CDN files... Worth a try though.