types.Attachment
types.Attachment()An image, PDF, or text file to attach to a chat message.
Construct via :meth:from_path, :meth:from_data, or :meth:from_url.
Methods
| Name | Description |
|---|---|
| from_data | Create an attachment from raw bytes. |
| from_path | Create an attachment from a filesystem path. |
| from_url | Create an attachment from a data URL or remote http(s) URL. |
from_data
types.Attachment.from_data(data, mime, *, name=None)Create an attachment from raw bytes.
from_path
types.Attachment.from_path(path, *, mime=None, name=None)Create an attachment from a filesystem path.
from_url
types.Attachment.from_url(url, *, mime=None, name=None)Create an attachment from a data URL or remote http(s) URL.
For data: URLs, the binary payload is decoded immediately to compute size. Remote http(s) URLs are stored as-is (no network request is made), so size will be 0.