From 69f939ad99240d98a64c8651f6f3de37e2c9647a Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 27 Apr 2024 12:13:28 +0800 Subject: [PATCH] Laravel Vapor - sync code for download files in bulk from S3 to more files --- .../BulkDownloadSupplierWhiteFormsLogic.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadSupplierWhiteFormsLogic.php b/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadSupplierWhiteFormsLogic.php index 32fadf03..60b8412c 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadSupplierWhiteFormsLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadSupplierWhiteFormsLogic.php @@ -55,10 +55,16 @@ class BulkDownloadSupplierWhiteFormsLogic foreach($groups as $group) { $document = $group->documents()->where('document_type', DocumentType::CURRENCY_VENDOR_ORDER)->whereNull('deleted_at')->first()->files()->first(); $created_at = $group->created_at->format('Y-m-d'); - $fileContent = Storage::disk('s3')->get('documents/'.$document->file->file_info->original->file); - $zip->addFromString('invoice-' . $created_at . "_" . $group->amount . "_" . $group->reference . '.pdf', $fileContent); + Log::info('BulkDownloadSupplierWhiteFormsLogic processing: ' . 'documents/'.$document->file->file_info->original->file); + if(!Storage::disk('s3')->exists('documents/'.$document->file->file_info->original->file)) + { + Log::info('BulkDownloadSupplierWhiteFormsLogic file does not exist: ' . 'documents/'.$document->file->file_info->original->file); + } + else{ + $fileContent = Storage::disk('s3')->get('documents/'.$document->file->file_info->original->file); + $zip->addFromString('invoice-' . $created_at . "_" . $group->amount . "_" . $group->reference . '.pdf', $fileContent); + } } - $zip->close(); return response()->download($zip_file);