Conditionally add content-type
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
017884f843
commit
c01190fac2
1 changed files with 8 additions and 4 deletions
|
@ -132,15 +132,19 @@ class UserFilesController extends Controller
|
||||||
$file = 'private_uploads/users/'.$log->filename;
|
$file = 'private_uploads/users/'.$log->filename;
|
||||||
|
|
||||||
|
|
||||||
if ((request('inline') == 'true') && (StorageHelper::allowSafeInline($file) === false)) {
|
|
||||||
|
|
||||||
// Display the file as text is not allowed for security reasons
|
if (request('inline') == 'true') {
|
||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Disposition' => 'inline',
|
'Content-Disposition' => 'inline',
|
||||||
'Content-Type' => 'text/plain',
|
|
||||||
];
|
];
|
||||||
return Storage::download($file, $log->filename, $headers);
|
|
||||||
|
|
||||||
|
// This is NOT allowed as inline - force it to be displayed as text
|
||||||
|
if (StorageHelper::allowSafeInline($file) === false) {
|
||||||
|
array_push($headers, ['Content-Type' => 'text/plain']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Storage::download($file, $log->filename, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Storage::download($file);
|
return Storage::download($file);
|
||||||
|
|
Loading…
Add table
Reference in a new issue