Adds a file to the 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 to add.
$mimeTypestring|nulloptional- Optional MIME type (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);
$this->parts[] = new MessagePart($file);
return $this;
}
Changelog
| Version | Description |
|---|---|
| 0.2.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.