Laravel Vapor - Fix a problem with fetching file from S3 bucket path inconsistency

This commit is contained in:
Dillon Ngo
2024-05-26 01:57:55 +08:00
parent d3bbed3ea6
commit 35bf735db3
2 changed files with 4 additions and 4 deletions
@@ -56,13 +56,13 @@ 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');
Log::info('BulkDownloadSupplierWhiteFormsLogic processing: ' . 'documents/'.$document->file->file_info->original->file);
Log::info('BulkDownloadSupplierWhiteFormsLogic processing: ' . $document->file->file_info->original->file);
if(!Storage::disk('s3')->exists($document->file->file_info->original->file))
{
Log::info('BulkDownloadSupplierWhiteFormsLogic file does not exist: ' . 'documents/'.$document->file->file_info->original->file);
Log::info('BulkDownloadSupplierWhiteFormsLogic file does not exist: ' . $document->file->file_info->original->file);
}
else{
$fileContent = Storage::disk('s3')->get('documents/'.$document->file->file_info->original->file);
$fileContent = Storage::disk('s3')->get($document->file->file_info->original->file);
$zip->addFromString('invoice-' . $created_at . "_" . $group->amount . "_" . $group->reference . '.pdf', $fileContent);
}
}
@@ -54,7 +54,7 @@ class PaymentProofUploadedEmail extends AbstractEmail
// $filesystemDriver = Storage::getDefaultDriver();
// if($filesystemDriver === 's3'){
// $fileContent = null;
// $fileContent = Storage::disk('s3')->get('documents/' . $file_path);
// $fileContent = Storage::disk('s3')->get($file_path);
// if ($fileContent) {
// $mailMessage->attachData($fileContent, 'invoice.pdf', [
// 'mime' => 'application/pdf',