From 6057f1e199ccf61d7f900524d75ea23ad589466e Mon Sep 17 00:00:00 2001 From: J0rdyV <28193980+J0rdyV@users.noreply.github.com> Date: Fri, 7 Jun 2024 11:13:53 +0200 Subject: [PATCH] Improved logging on FileUpload when failed --- src/Bynder/Api/Impl/Upload/FileUploader.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Bynder/Api/Impl/Upload/FileUploader.php b/src/Bynder/Api/Impl/Upload/FileUploader.php index fc890cf..89a227e 100644 --- a/src/Bynder/Api/Impl/Upload/FileUploader.php +++ b/src/Bynder/Api/Impl/Upload/FileUploader.php @@ -144,11 +144,16 @@ function ($response) use ($finalizeResponse) { ) ->then( function ($value) use ($data) { - if ($value['pollStatus'] != false) { - $data['importId'] = $value['finalizeData']['importId']; - return $this->saveMediaAsync($data); + $originalFilename = isset($value['finalizeData']['originalFilename']) ? $value['finalizeData']['originalFilename'] : 'unknown'; + if (!empty($value['pollStatus']) && is_array($value['pollStatus'])) { + if (isset($value['finalizeData']['importId'])) { + $data['importId'] = $value['finalizeData']['importId']; + return $this->saveMediaAsync($data); + } else { + throw new Exception("Missing importId in finalizeData for file: $originalFilename."); + } } else { - throw new Exception("Converter did not finish. Upload failed."); + throw new Exception("Converter did not finish. Upload failed for file: $originalFilename."); } } );