File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,11 @@ public function create(): RequestInterface
118118
119119 if ($ this ->data ['method ' ] !== self ::HTTP_GET ) {
120120 curl_setopt ($ this ->curl , CURLOPT_POST , true );
121- curl_setopt ($ this ->curl , CURLOPT_POSTFIELDS , json_encode ($ this ->data ['fields ' ]));
121+ if ($ this ->isMultipart ()) {
122+ curl_setopt ($ this ->curl , CURLOPT_POSTFIELDS , $ this ->data ['fields ' ]);
123+ } else {
124+ curl_setopt ($ this ->curl , CURLOPT_POSTFIELDS , json_encode ($ this ->data ['fields ' ]));
125+ }
122126 }
123127
124128 $ request = new Request ($ this ->curl );
@@ -137,7 +141,7 @@ private function buildHeaders(): array
137141 {
138142 $ headers = [
139143 ZohoOAuthConstants::AUTHORIZATION . ': ' . ZohoOAuthConstants::OAUTH_HEADER_PREFIX . $ this ->client ->getAccessToken (),
140- 'Content-Type:application/json '
144+ 'Content-Type: ' . ( $ this -> isMultipart () ? ' multipart/form-data ' : ' application/json '),
141145 ];
142146
143147 if ($ this ->client ->getOrgId ()) {
@@ -147,6 +151,10 @@ private function buildHeaders(): array
147151 return $ headers ;
148152 }
149153
154+ private function isMultipart () {
155+ return isset ($ this ->data ['fields ' ]['file ' ]) && $ this ->data ['fields ' ]['file ' ] instanceof \CURLFile;
156+ }
157+
150158 private function buildUrl (): string
151159 {
152160 $ url = sprintf (
You can’t perform that action at this time.
0 commit comments