public function prepareFileUploadRequest(array $files, $relativePath = null, array $data = [], array $query = [])
    {
        $request = $this->prepareRequest('POST', $relativePath, [], $query);
        $request->getHeaders()->removeHeader($request->getHeaders()->get('Content-Type'));

        $this->httpClient->setRequest($request);

        foreach ($files as $formName => $filePath) {
            $this->httpClient->setFileUpload($filePath, $formName);

            if (isset($data[$formName])) {
                $file = $request->getFiles()->get($filePath, null);

                if ($file) { // If present, override the filename
                    $file['filename'] = $data[$formName];
                    $request->getFiles()->set($filePath, $file);
                }

                unset($data[$formName]);
            }
        }

        $request->getPost()->fromArray($data);

        return $request;
    }