-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download a file after custom process #118
Comments
sorry @afbora for the late reply. does sending the header::download and exit as described in the readme not work? |
No problem. Thanks for the reply. I think the
Here my job and it doesn't work (401: Unauthenticated error). What am I doing wrong? <?php
class downloadOrders extends \Bnomei\JanitorJob
{
public function job(): array
{
$zipFile = kirby()->root() . "/export.zip";
$zipArchive = new ZipArchive();
if ($zipArchive->open($zipFile, (ZipArchive::CREATE | ZipArchive::OVERWRITE)) !== true) {
die("Failed to create archive\n");
}
$files = Dir::read(kirby()->root() . '/orders', null, true);
foreach ($files as $file) {
$zipArchive->addFile($file, basename($file));
}
$zipArchive->close();
Header::download([
'mime' => F::mime($zipFile),
'name' => F::filename($zipFile),
]);
readfile($zipFile);
die();
return [
'status' => 200
];
}
} |
Hey!
I'm trying to make a process that create custom zip file and download the zip file when client click the button. I tried with
janitor:download
andjob
, couldn't do that.janitor:download
doesn't work because endpoint route is not a file, this is a process. After zip file created, download should be started. Returns 404 when I set the route that handle the zip file.job
doesn't work because I can't start download process in a job or return download file path. Zip file created but download doesn't start.Any help please?
The text was updated successfully, but these errors were encountered: