diff --git a/src/Body/FormBody.php b/src/Body/FormBody.php index 83358210..2a2c83ac 100644 --- a/src/Body/FormBody.php +++ b/src/Body/FormBody.php @@ -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