Added pdf shown logic in request characteristics route
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 18s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 23s
Laravel Pint / pint (pull_request) Successful in 5m3s
Laravel Larastan / larastan (pull_request) Failing after 11m53s

This commit is contained in:
dhanabalan
2026-12-01 15:34:11 +05:30
parent c342d54c7b
commit 7ca4eec965

View File

@@ -141,14 +141,43 @@ Route::get('/part-validation-image/{filename}', function ($filename) {
return response()->file($path);
})->name('part.validation.image');
Route::get('/workflow-image/{filename}', function ($filename) {
$path = storage_path("app/private/uploads/LaserDocs/{$filename}");
// Route::get('/workflow-image/{filename}', function ($filename) {
// $path = storage_path("app/private/uploads/LaserDocs/{$filename}");
if (! file_exists($path)) {
abort(404, 'Image not found');
// if (! file_exists($path)) {
// abort(404, 'Image not found');
// }
// return response()->file($path);
// })->name('workflow.image');
Route::get('/workflow-image/{filename}', function ($filename) {
$directory = storage_path('app/private/uploads/LaserDocs');
$files = glob($directory . '/' . basename($filename));
if (empty($files)) {
abort(404, 'File not found');
}
return response()->file($path);
$path = $files[0];
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
if ($extension === 'pdf') {
return response()->file($path, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="' . basename($path) . '"',
]);
}
if (in_array($extension, ['png', 'jpg', 'jpeg'])) {
return response()->file($path);
}
abort(403, 'Unsupported file format');
})->name('workflow.image');
// web.php