I'm seeing some strange behaviour on our live site, which is running on Digital Ocean behind a load balancer.
On the production site, running:
return response()->streamDownload(
function() use ($resource) {
echo Storage::get('path-to-file');
}, $resource->file, [
'Content-Type' => $resource->mime_type,
'Content-Disposition' => 'inline; filename="' . $resource->file . '"'
], 'inline');
Works as expected in Firefox where it shows an inline preview of the file (a PDF file in this case), but in Chrome & Edge it returns plain text beginning with:
%PDF-1.6
%âãÏÓ
269 0 obj
<</Linearized 1/L 276797/O 271/...
Does anybody know what might be causing this? The code is the same, and if I change 'inline' to 'attachment', the file downloads successfully.
I thought this issue might be related to being behind a proxy, or a file size set incorrectly, but the fact that it works in non-chrome browsers is confusing.