Adds a file to the current message.
Description
Accepts:
- File object
- URL string (remote file)
- Base64-encoded data string
- Data URI string (data:mime/type;base64,data)
- Local file path string
Parameters
$filestring|WordPressAiClientFilesDTOFilerequired- The file (File object or string representation).
$mimeTypestring|nulloptional- The MIME type (optional, ignored if File object provided).
Default:
null
Source
public function withFile($file, ?string $mimeType = null): self
{
$file = $file instanceof File ? $file : new File($file, $mimeType);
$part = new MessagePart($file);
$this->appendPartToMessages($part);
return $this;
}
Changelog
| Version | Description |
|---|---|
| 0.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.