Skip to content

Commit

Permalink
Add addFileFromString method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pato05 committed Jul 13, 2020
1 parent ba5d824 commit a3648a6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Body/FormBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ public function addFiles(array $data, string $contentType = 'application/octet-s
}
}

/**
* Add a file field to the form from a string.
*
* @param string $name
* @param string $fileContent
* @param string $fileName
* @param string $contentType
*/
public function addFileFromString(string $name, string $fileContent, string $fileName, string $contentType = 'application/octet-stream'): void
{
$this->fields[] = [$name, $fileContent, $contentType, $fileName];
$this->isMultipart = true;
$this->resetCache();
}

/**
* Returns an array of fields, each being an array of [name, value, content-type, file-name|null].
* Both fields and files are returned in the array. Files use a FileBody object as the value. The file-name is
Expand Down

0 comments on commit a3648a6

Please sign in to comment.