Files
api/services/nginx/app/file_server.php
T
Jepp9350 ca52d3b248 Update API endpoints, add wash certificate handling
Replaced legacy 'nnks.truckwash.dk' endpoint with 'api.truckwash.dk' across the codebase for consistency. Implemented a feature to handle certificate downloads, including file serving and validation. Updated PHP configuration to support additional dependencies like PHPMailer, and introduced necessary route and configuration changes for wash certificate processing.
2025-01-31 09:25:18 +01:00

23 lines
779 B
PHP

<?php
// Get the file name from the URL
$file = $_SERVER['REQUEST_URI'];
$file = str_replace('/modules/washcertificates/output/certificates/', '', $file);
// Download the file from minio, and send it to the client
$wash_certificate_store = new \classes\wash_certificate_store();
// Check if the certificate exists
if (!$wash_certificate_store->washCertificateExists($file)) {
header('HTTP/1.1 404 Not Found');
exit;
}
// Download the certificate from the store to /tmp
$certificate_path = $wash_certificate_store->download($file);
// Send the certificate to the client
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $file . '"');
header('Content-Length: ' . filesize($certificate_path));
readfile($certificate_path);
exit;