MessageBuilder::withFile( string|WordPressAiClientFilesDTOFile $file, string|null $mimeType = null ): self

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

Return

self

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

VersionDescription
0.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.