Skip to content

Commit

Permalink
replace form-data by form-urlencoded (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
synicko authored May 22, 2023
1 parent b6b1e2c commit cd19629
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 642 deletions.
19 changes: 6 additions & 13 deletions src/Api/CollectorApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
namespace PrestaShop\Module\PsEventbus\Api;

use GuzzleHttp\Psr7\Request;
use PrestaShop\Module\PsEventbus\Api\Post\MultipartBody;
use PrestaShop\Module\PsEventbus\Api\Post\PostFileApi;
use PrestaShop\Module\PsEventbus\Config\Config;
use Prestashop\ModuleLibGuzzleAdapter\ClientFactory;
use Prestashop\ModuleLibGuzzleAdapter\Interfaces\HttpClientInterface;
use PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts;
Expand Down Expand Up @@ -72,20 +69,18 @@ public function upload(string $jobId, string $data, int $startTime, bool $fullSy
{
$url = $this->collectorApiUrl . '/upload/' . $jobId;
// Prepare request
$file = new PostFileApi('file', $data, 'file');
$multipartBody = new MultipartBody([], [$file], Config::COLLECTOR_MULTIPART_BOUNDARY);
$request = new Request(
'POST',
$url,
[
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $this->jwt,
'Content-Length' => $file->getContent()->getSize(),
'Content-Type' => 'multipart/form-data; boundary=' . Config::COLLECTOR_MULTIPART_BOUNDARY,
'Content-Length' => strlen($data),
'Content-Type' => 'application/x-www-form-urlencoded',
'Full-Sync-Requested' => $fullSyncRequested ? '1' : '0',
'User-Agent' => 'ps-eventbus/' . $this->module->version,
],
$multipartBody->getContents()
'lines=' . urlencode($data)
);

// Send request and parse response
Expand Down Expand Up @@ -114,19 +109,17 @@ public function uploadDelete(string $jobId, string $data, int $startTime)
{
$url = $this->collectorApiUrl . '/delete/' . $jobId;
// Prepare request
$file = new PostFileApi('file', $data, 'file');
$multipartBody = new MultipartBody([], [$file], Config::COLLECTOR_MULTIPART_BOUNDARY);
$request = new Request(
'POST',
$url,
[
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $this->jwt,
'Content-Length' => $file->getContent()->getSize(),
'Content-Type' => 'multipart/form-data; boundary=' . Config::COLLECTOR_MULTIPART_BOUNDARY,
'Content-Length' => strlen($data),
'Content-Type' => 'application/x-www-form-urlencoded',
'User-Agent' => 'ps-eventbus/' . $this->module->version,
],
$multipartBody->getContents()
'lines=' . urlencode($data)
);

// Send request and parse response
Expand Down
130 changes: 0 additions & 130 deletions src/Api/Post/MultipartBody.php

This file was deleted.

149 changes: 0 additions & 149 deletions src/Api/Post/PostFileApi.php

This file was deleted.

42 changes: 0 additions & 42 deletions src/Api/Post/PostFileInterface.php

This file was deleted.

Loading

0 comments on commit cd19629

Please sign in to comment.