FilesAccessor Class
Accessor for the uploaded files on the current inbound activity, exposed as ctx.files.
"Files" is the uploaded-file view over the raw ctx.activity.attachments array. Uploaded files arrive as attachments where content_type is file.download.info, carrying file metadata rather than the bytes themselves. The metadata names where the bytes live: a pre-authorized download_url when the platform issues one, otherwise a content_url that locates the item so Graph can resolve it. This accessor maps each to an IncomingFile, and skips everything else in attachments (adaptive cards, mentions, other non-file content) as well as malformed file entries, never throwing. For each file it returns, the original wire attachment (the metadata object, not the bytes) is retained on IncomingFile.raw. A malformed or non-file attachment is reachable only through the raw activity.attachments array.
This covers the file-upload path, not "any uploaded media". What matters is how the content arrived, not the file's MIME type, so file type is unrestricted (pdf, docx, png, etc.) as long as it was sent as an uploaded file. An image sent as a file appears here, but the same image pasted inline does not.
The optional client is the app's shared httpx.AsyncClient, threaded into every IncomingFile so downloads reuse one connection pool instead of building and tearing down a client per file. It is the raw client rather than the SDK's wrapper on purpose: a download URL embeds its own tempauth credential, so the request must not pick up the bot's Authorization header. When omitted, each download creates and closes its own client.
Constructor
FilesAccessor(activity: Activity, client: AsyncClient | None = None, credential: GraphCredential | None = None)
Parameters
| Name | Description |
|---|---|
|
activity
Required
|
|
|
client
|
Default value: None
|
|
credential
|
Default value: None
|
Methods
| first |
Convenience: the first attached file, or None when none. Sugar over list()[0]; shares list()'s resolution so it stays correct when later scopes hydrate through Graph. |
| list |
The files attached to the current inbound activity. Async because later scopes hydrate through Graph; the personal path resolves synchronously from the activity but keeps the async signature so the shape never breaks. Currently takes no arguments and returns only uploaded files. The signature is reserved to grow options later (e.g. include_inline_images, content_types, include_raw) so coverage can widen opt-in without a break; the default stays narrow. |
first
Convenience: the first attached file, or None when none. Sugar over list()[0]; shares list()'s resolution so it stays correct when later scopes hydrate through Graph.
async first() -> IncomingFile | None
list
The files attached to the current inbound activity. Async because later scopes hydrate through Graph; the personal path resolves synchronously from the activity but keeps the async signature so the shape never breaks.
Currently takes no arguments and returns only uploaded files. The signature is reserved to grow options later (e.g. include_inline_images, content_types, include_raw) so coverage can widen opt-in without a break; the default stays narrow.
async list() -> list[microsoft_teams.apps.files.incoming_file.IncomingFile]