Skip to content

Image attachments

When enable_file_attach is on, the composer shows a paperclip. Picked photos can travel two ways:

1. Inline (zero setup)

Without an uploader, the SDK sends the image as base64 in the chat request (image_b64). Fine for prototyping. The SDK resizes before sending; the backend caps inline images at ~8 MB encoded.

Wire an uploader: the SDK hands you the bytes, you upload to your own storage (Firebase Storage, S3, …) and return an HTTPS URL. The chat request then carries image_url instead of inline bytes — keeping the backend DB tiny and letting clients render from a CDN.

ChatWidget(
configuration: config,
imageUploader: (bytes, mime) async {
final url = await myStorage.upload(bytes, mime); // must be https://
return url;
},
);

imageUploader is Future<String> Function(Uint8List bytes, String mimeType). Throw to fall back to the inline path for that one upload.

Gating

For a JWT-authed upload endpoint, only offer the paperclip to signed-in users — set enableFileAttach: session.isAuthenticated on the host config, and have the uploader throw for guests. You can also require consent (e.g. an AI-data-sharing prompt) before the first upload.