From cd5ef00fbe3b45503db47a653f48ba1a7f460615 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Thu, 28 Jun 2018 23:48:08 +0300 Subject: [PATCH] multipart need to upload images --- src/Client/YouTrackClient.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Client/YouTrackClient.php b/src/Client/YouTrackClient.php index bd63cf9..f445e75 100644 --- a/src/Client/YouTrackClient.php +++ b/src/Client/YouTrackClient.php @@ -225,14 +225,20 @@ protected function buildOptions(array $params = [], $options = []): array 'headers' => $this->buildHeaders(), ]; - if (isset($options['form_params'])) { + if (!isset($options['multipart']) && isset($options['form_params'])) { $options['form_params'] = array_merge($params, $options['form_params']); } + + if (isset($options['multipart'])) { + unset($defaultOptions['form_params']); + foreach ($params as $key => $value) { + $options['multipart'][] = ['name' => $key, 'data' => $value]; + } + } if (isset($options['headers'])) { $options['headers'] = array_merge($this->buildHeaders(), $options['headers']); } - return array_merge($defaultOptions, $options); }