WordPress\AiClient\Builders

MessageBuilder::withFilepublicWP 0.2.0

Adds a file to the message.

Accepts:

  • File object
  • URL string (remote file)
  • Base64-encoded data string
  • Data URI string (data:mime/type;base64,data)
  • Local file path string

Method of the class: MessageBuilder{}

No Hooks.

Returns

self.

Usage

$MessageBuilder = new MessageBuilder();
$MessageBuilder->withFile( $file, ?string $mimeType ): self;
$file(string|File) (required)
The file to add.
?string $mimeType
.
Default: null

Changelog

Since 0.2.0 Introduced.

MessageBuilder::withFile() code WP 7.0

public function withFile($file, ?string $mimeType = null): self
{
    $file = $file instanceof File ? $file : new File($file, $mimeType);
    $this->parts[] = new MessagePart($file);
    return $this;
}