mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
Laravel Vapor - Fix a problem with fetching file from S3 bucket path inconsistency
This commit is contained in:
@@ -53,7 +53,7 @@ class EmailDoToVTV2CommandJob implements ShouldQueue
|
||||
//STEP 1: Go through each of the booking from query
|
||||
foreach ($bookings as $booking) {
|
||||
$file = $booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first();
|
||||
$fileContent = Storage::disk('s3')->get('documents/'.$file->file->file_info->original->file);
|
||||
$fileContent = Storage::disk('s3')->get($file->file->file_info->original->file);
|
||||
$zip->addFromString($booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf', $fileContent);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class TestAttachingS3FileAndSendEmailV2CommandJob implements ShouldQueue
|
||||
$counter = 0;
|
||||
foreach ($bookings as $booking) {
|
||||
$file = $booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first();
|
||||
$fileContent = Storage::disk('s3')->get('documents/'.$file->file->file_info->original->file);
|
||||
$fileContent = Storage::disk('s3')->get($file->file->file_info->original->file);
|
||||
$zip->addFromString($booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf', $fileContent);
|
||||
|
||||
$counter++;
|
||||
|
||||
@@ -59,21 +59,21 @@ class DownloadBookingDocumentLogic
|
||||
if ($document_type == 'INVOICEPODOSDO') {
|
||||
$supplier_deliver_order_file = $booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first();
|
||||
}
|
||||
$fileContent = Storage::disk('s3')->get('documents/'.$invoice_file->file->file_info->original->file);
|
||||
$fileContent = Storage::disk('s3')->get($invoice_file->file->file_info->original->file);
|
||||
$zip->addFromString('invoice-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf', $fileContent);
|
||||
|
||||
$fileContent = Storage::disk('s3')->get('documents/'.$purchase_file->file->file_info->original->file);
|
||||
$fileContent = Storage::disk('s3')->get($purchase_file->file->file_info->original->file);
|
||||
$zip->addFromString('purchase-order-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf', $fileContent);
|
||||
|
||||
$fileContent = Storage::disk('s3')->get('documents/'.$deliver_file->file->file_info->original->file);
|
||||
$fileContent = Storage::disk('s3')->get($deliver_file->file->file_info->original->file);
|
||||
$zip->addFromString('deliver-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf', $fileContent);
|
||||
|
||||
$fileContent = Storage::disk('s3')->get('documents/'.$supplier_deliver_order_file->file->file_info->original->file);
|
||||
$fileContent = Storage::disk('s3')->get($supplier_deliver_order_file->file->file_info->original->file);
|
||||
$zip->addFromString('supplier-deliver-order-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf', $fileContent);
|
||||
}
|
||||
else {
|
||||
$file = $booking->documents()->where('document_type', $document_type)->first()->files()->first();
|
||||
$fileContent = Storage::disk('s3')->get('documents/'.$file->file->file_info->original->file);
|
||||
$fileContent = Storage::disk('s3')->get($file->file->file_info->original->file);
|
||||
$zip->addFromString($booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf', $fileContent);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class BulkDownloadCustomerInvoicesLogic
|
||||
if ($zip->open($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
|
||||
foreach ($invoicebookings as $booking) {
|
||||
$invoice_file = $booking->documents()->where('document_type', DocumentType::INVOICE)->whereNull('deleted_at')->first()->files()->first();
|
||||
$fileContent = Storage::disk('s3')->get('documents/'.$invoice_file->file->file_info->original->file);
|
||||
$fileContent = Storage::disk('s3')->get($invoice_file->file->file_info->original->file);
|
||||
$zip->addFromString('invoice-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf', $fileContent);
|
||||
}
|
||||
$zip->close();
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ class BulkDownloadSupplierWhiteFormsLogic
|
||||
$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);
|
||||
if(!Storage::disk('s3')->exists('documents/'.$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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user