I want to download zip files (fromt 200mb up to 3GB) from an FTP-Server to the local directory of my applications server. Therefor I've written a job with takes the filename, constructs the relevant paths/directories and then streams the file from ftp to local directory. Unfortunately the job keeps failing for large files with the following message:
Illuminate\Queue\MaxAttemptsExceededException: App\Jobs\DownloadFileFromFtp has been attempted too many times or run too long. The job may have previously timed out. in /home/forge/staging.vehicle-service.faaren-global.de/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:648
I'm running the queue worker via php artisan queue:work --timeout=0 so there should be no timeout.
This is my job:
private function downloadFIleFromFtp(): bool
{
try {
if(!file_exists(storage_path('app/temp/'))){
mkdir(storage_path('app/temp/'));
}
$destination = storage_path('app/temp/' . $this->import->unique_filename);
$ftpDisk = Storage::disk($this->import->disk);
$stream = $ftpDisk
->getDriver()
->readStream($this->import->filename);
file_put_contents($destination, stream_get_contents($stream), FILE_APPEND);
return true;
} catch(\Exception $ex){
$log = ImportLog::createWithException($ex, "Download from ftp failed");
$this->import->logs()->save($log);
return false;
}
}