mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-22 05:53:58 +00:00
Laravel Vapor - Code Sync from Shipping Portal to use S3 Bucket to replace local storage
This commit is contained in:
@@ -20,14 +20,28 @@ class Convert1688PurchaseOrderToProductList
|
||||
$productList = [];
|
||||
$shipping = 0;
|
||||
$discount = 0;
|
||||
$text = "";
|
||||
$filepath = "";
|
||||
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
$file = $file->file->file_info->original->file;
|
||||
if($filesystemDriver === 's3'){
|
||||
$fileContent = Storage::disk('s3')->get($file);
|
||||
$filepath = storage_path('app/temp.pdf');
|
||||
file_put_contents($filepath, $fileContent);
|
||||
}
|
||||
else{
|
||||
$filepath = Storage::disk('documents')->path($file);
|
||||
}
|
||||
|
||||
try {
|
||||
$pdf = $parser->parseFile(Storage::disk('documents')->path($file->file->file_info->original->file));
|
||||
$pdf = $parser->parseFile($filepath);
|
||||
$text = $pdf->getText();
|
||||
} catch (Exception $exception) {
|
||||
throw new MalformedRequestException('Invalid file format.');
|
||||
}
|
||||
|
||||
$text = $pdf->getText();
|
||||
|
||||
if(str_contains($text, '订单详情单')) throw new MalformedRequestException('Can\'t process non english documents');
|
||||
|
||||
$tables = explode('Amount (yuan)', $text);
|
||||
|
||||
Reference in New Issue
Block a user