Skip to content

Commit 17636e8

Browse files
committed
refactor: buildDataFiles
1 parent e7f07de commit 17636e8

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/Client.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public function uploadPhoto($uri, $file)
430430
$boundary = uniqid();
431431
$delimiter = '-------------'.$boundary;
432432

433-
$postData = $this->buildDataFiles($boundary, $fields, $files);
433+
$postData = $this->buildDataFiles($boundary, $files);
434434

435435
$url = $this->baseUrl.$uri;
436436
$ch = curl_init();
@@ -467,23 +467,17 @@ public function uploadPhoto($uri, $file)
467467
/**
468468
* @return string file content and post data
469469
*/
470-
public function buildDataFiles($boundary, $fields, $files)
470+
public function buildDataFiles($boundary, array $files): string
471471
{
472472
$data = '';
473473
$eol = "\r\n";
474474

475475
$delimiter = '-------------'.$boundary;
476476

477-
foreach ($fields as $name => $content) {
478-
$data .= '--'.$delimiter.$eol
479-
.'Content-Disposition: form-data; name="'.$name.'"'.$eol.$eol
480-
.$content.$eol;
481-
}
482-
483477
foreach ($files as $name => $content) {
484478
$data .= '--'.$delimiter.$eol
485-
.'Content-Disposition: form-data; name="'.$name.'"; filename="'.$name.'"'.$eol
486-
//. 'Content-Type: image/png'.$eol
479+
.'Content-Disposition: form-data; name="'.$name.'"; filename="'.$name.'.png"'.$eol
480+
.'Content-Type: image/png'.$eol
487481
.'Content-Transfer-Encoding: binary'.$eol
488482
;
489483

0 commit comments

Comments
 (0)