|
8 | 8 | use GuzzleHttp\Client;
|
9 | 9 | use GuzzleHttp\Psr7\Request;
|
10 | 10 |
|
| 11 | +use Filestack\Mixins\LoggingTrait; |
| 12 | + |
11 | 13 | /**
|
12 | 14 | * Object used by the Filestack client to process an
|
13 | 15 | * upload task.
|
14 | 16 | */
|
15 | 17 | class UploadProcessor
|
16 | 18 | {
|
17 | 19 | use Mixins\CommonMixin;
|
| 20 | + use LoggingTrait; |
18 | 21 |
|
19 | 22 | public $api_key;
|
20 | 23 | protected $security;
|
@@ -98,8 +101,15 @@ public function registerUploadTask($api_key, $metadata)
|
98 | 101 | $this->appendSecurity($data);
|
99 | 102 |
|
100 | 103 | $url = $this->getCustomUrl(FilestackConfig::UPLOAD_URL) . '/multipart/start';
|
| 104 | + |
| 105 | + $this->log("Method: POST"); |
| 106 | + $this->log("URL: " . $url); |
| 107 | + $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); |
| 108 | + |
101 | 109 | $response = $this->sendRequest('POST', $url, ['multipart' => $data]);
|
| 110 | + |
102 | 111 | $json = $this->handleResponseDecodeJson($response);
|
| 112 | + $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); |
103 | 113 |
|
104 | 114 | return $json;
|
105 | 115 | }
|
@@ -322,8 +332,16 @@ protected function processChunks($part, $chunks)
|
322 | 332 | $part['part_size'] += $current_chunk['size'];
|
323 | 333 |
|
324 | 334 | $data = $this->buildChunkData($part, $current_chunk);
|
| 335 | + |
| 336 | + $this->log("Method: POST"); |
| 337 | + $this->log("URL: " . $upload_url); |
| 338 | + $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); |
| 339 | + |
325 | 340 | $response = $this->sendRequest('POST', $upload_url, ['multipart' => $data]);
|
326 | 341 |
|
| 342 | + $json = $this->handleResponseDecodeJson($response); |
| 343 | + $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); |
| 344 | + |
327 | 345 | try {
|
328 | 346 | $json = $this->handleResponseDecodeJson($response);
|
329 | 347 | $url = $json['url'];
|
@@ -463,9 +481,17 @@ protected function registerComplete($api_key, $parts_etags, $upload_data,
|
463 | 481 | $this->appendSecurity($data);
|
464 | 482 |
|
465 | 483 | $url = $this->getCustomUrl(FilestackConfig::UPLOAD_URL) . '/multipart/complete';
|
| 484 | + |
| 485 | + $this->log("Method: POST"); |
| 486 | + $this->log("URL: " . $url); |
| 487 | + $this->log("Input Data: " . json_encode($data, JSON_PRETTY_PRINT)); |
| 488 | + |
466 | 489 | $response = $this->sendRequest('POST', $url, ['multipart' => $data]);
|
467 | 490 | $status_code = $response->getStatusCode();
|
468 | 491 |
|
| 492 | + $json = $this->handleResponseDecodeJson($response); |
| 493 | + $this->log("Output Data: " . json_encode($json, JSON_PRETTY_PRINT)); |
| 494 | + |
469 | 495 | $filelink = null;
|
470 | 496 | if ($status_code == 200) {
|
471 | 497 | $filelink = $this->handleResponseCreateFilelink($response);
|
|
0 commit comments