From e2e2f75192500781d6280ff7ad59c41b564a1df8 Mon Sep 17 00:00:00 2001 From: shanmugam001 <102345970+shanmugam001@users.noreply.github.com> Date: Tue, 10 Sep 2024 23:01:39 +0530 Subject: [PATCH 1/3] Update UploadProcessor.php --- filestack/UploadProcessor.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/filestack/UploadProcessor.php b/filestack/UploadProcessor.php index 64acf38..1da0593 100644 --- a/filestack/UploadProcessor.php +++ b/filestack/UploadProcessor.php @@ -8,6 +8,8 @@ use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; +use Filestack\Mixins\LoggingTrait; + /** * Object used by the Filestack client to process an * upload task. @@ -15,6 +17,7 @@ class UploadProcessor { use Mixins\CommonMixin; + use LoggingTrait; public $api_key; protected $security; @@ -98,8 +101,15 @@ public function registerUploadTask($api_key, $metadata) $this->appendSecurity($data); $url = $this->getCustomUrl(FilestackConfig::UPLOAD_URL) . '/multipart/start'; + + $this->log("Method: POST"); + $this->log("URL: " . $url); + $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); + $response = $this->sendRequest('POST', $url, ['multipart' => $data]); + $json = $this->handleResponseDecodeJson($response); + $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); return $json; } @@ -322,8 +332,16 @@ protected function processChunks($part, $chunks) $part['part_size'] += $current_chunk['size']; $data = $this->buildChunkData($part, $current_chunk); + + $this->log("Method: POST"); + $this->log("URL: " . $upload_url); + $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); + $response = $this->sendRequest('POST', $upload_url, ['multipart' => $data]); + $json = $this->handleResponseDecodeJson($response); + $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); + try { $json = $this->handleResponseDecodeJson($response); $url = $json['url']; @@ -463,9 +481,17 @@ protected function registerComplete($api_key, $parts_etags, $upload_data, $this->appendSecurity($data); $url = $this->getCustomUrl(FilestackConfig::UPLOAD_URL) . '/multipart/complete'; + + $this->log("Method: POST"); + $this->log("URL: " . $url); + $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); + $response = $this->sendRequest('POST', $url, ['multipart' => $data]); $status_code = $response->getStatusCode(); + $json = $this->handleResponseDecodeJson($response); + $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); + $filelink = null; if ($status_code == 200) { $filelink = $this->handleResponseCreateFilelink($response); From d972d4929a55d6bcfe10ce25d35dc403e927a4cc Mon Sep 17 00:00:00 2001 From: shanmugam001 <102345970+shanmugam001@users.noreply.github.com> Date: Tue, 10 Sep 2024 23:07:03 +0530 Subject: [PATCH 2/3] Add files via upload --- filestack/mixins/LoggingTrait.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 filestack/mixins/LoggingTrait.php diff --git a/filestack/mixins/LoggingTrait.php b/filestack/mixins/LoggingTrait.php new file mode 100644 index 0000000..852ce4a --- /dev/null +++ b/filestack/mixins/LoggingTrait.php @@ -0,0 +1,26 @@ + Date: Wed, 11 Sep 2024 21:06:15 +0530 Subject: [PATCH 3/3] Revert log files --- filestack/UploadProcessor.php | 26 -------------------------- filestack/mixins/LoggingTrait.php | 26 -------------------------- 2 files changed, 52 deletions(-) delete mode 100644 filestack/mixins/LoggingTrait.php diff --git a/filestack/UploadProcessor.php b/filestack/UploadProcessor.php index 1da0593..64acf38 100644 --- a/filestack/UploadProcessor.php +++ b/filestack/UploadProcessor.php @@ -8,8 +8,6 @@ use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; -use Filestack\Mixins\LoggingTrait; - /** * Object used by the Filestack client to process an * upload task. @@ -17,7 +15,6 @@ class UploadProcessor { use Mixins\CommonMixin; - use LoggingTrait; public $api_key; protected $security; @@ -101,15 +98,8 @@ public function registerUploadTask($api_key, $metadata) $this->appendSecurity($data); $url = $this->getCustomUrl(FilestackConfig::UPLOAD_URL) . '/multipart/start'; - - $this->log("Method: POST"); - $this->log("URL: " . $url); - $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); - $response = $this->sendRequest('POST', $url, ['multipart' => $data]); - $json = $this->handleResponseDecodeJson($response); - $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); return $json; } @@ -332,16 +322,8 @@ protected function processChunks($part, $chunks) $part['part_size'] += $current_chunk['size']; $data = $this->buildChunkData($part, $current_chunk); - - $this->log("Method: POST"); - $this->log("URL: " . $upload_url); - $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); - $response = $this->sendRequest('POST', $upload_url, ['multipart' => $data]); - $json = $this->handleResponseDecodeJson($response); - $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); - try { $json = $this->handleResponseDecodeJson($response); $url = $json['url']; @@ -481,17 +463,9 @@ protected function registerComplete($api_key, $parts_etags, $upload_data, $this->appendSecurity($data); $url = $this->getCustomUrl(FilestackConfig::UPLOAD_URL) . '/multipart/complete'; - - $this->log("Method: POST"); - $this->log("URL: " . $url); - $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); - $response = $this->sendRequest('POST', $url, ['multipart' => $data]); $status_code = $response->getStatusCode(); - $json = $this->handleResponseDecodeJson($response); - $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); - $filelink = null; if ($status_code == 200) { $filelink = $this->handleResponseCreateFilelink($response); diff --git a/filestack/mixins/LoggingTrait.php b/filestack/mixins/LoggingTrait.php deleted file mode 100644 index 852ce4a..0000000 --- a/filestack/mixins/LoggingTrait.php +++ /dev/null @@ -1,26 +0,0 @@ -