Microsoft.Teams.Apps.Files Namespace

Classes

Name Description
DownloadedFile

A buffered, point-in-time snapshot of a downloaded file's bytes that the caller owns.

Returned by DownloadAsync(CancellationToken). The bytes are already in memory, so the convenience readers here are synchronous and never re-download. Because it is a snapshot, holding one and reusing it is the way to read the same file several ways without re-fetching through the live IncomingFile handle.

FileAccessException

Raised when the identity used was refused by the storage service.

Distinct from FileUrlExpiredException, which is terminal: a pre-authorized URL lapsed, and the SDK does not resolve those bytes another way even when a contentUrl and a Graph credential are both present. This exception means the Graph route was the one that failed, refused by the service after the request was made.

FileConsentExtensions

Extension methods for registering file consent invoke handlers.

FileConsentValue

Represents the value of the invoke activity sent when the user acts on a file consent card.

FileCredentialException

Raised when no credential was available for the Graph call. Detectable before any HTTP request.

Distinct from FileUrlExpiredException, which is terminal: a pre-authorized URL lapsed, and the SDK does not resolve those bytes another way even when a contentUrl and a Graph credential are both present. This exception means the Graph route was ruled out before the request, because no usable credential was available: either a token could not be acquired, or the one acquired carries no file-capable permission.

FileDownloader

Opens byte streams for inbound files, keyed on conversation scope so every scope's receive path extends this one place rather than branching in callers.

FileDownloadInfo

The content of a file.download.info attachment, describing an uploaded file received in a personal (1:1) chat. The file is fetched from the short-lived, pre-authorized DownloadUrl with a plain GET (no bearer token).

FileException

Base class for the diagnosable failures on the inbound-file path: an expired URL, an unsupported scope, and a refused Graph read.

Lets a caller catch those with one catch clause, so a new one can be added without callers changing. A transport or service failure the SDK cannot attribute, such as a Graph 5xx, is not one of these and surfaces as an HttpRequestException.

FilesAccessor

Accessor for the uploaded files on the current inbound activity, exposed as ctx.Files. Reads the files attached to the current inbound activity and exposes them as lazy IncomingFile handles.

"Files" is the uploaded-file view over the raw ctx.Activity.Attachments list. Uploaded files arrive as attachments where ContentType is file.download.info, carrying file metadata rather than the bytes themselves. The metadata names where the bytes live: a pre-authorized downloadUrl when the platform issues one, otherwise a contentUrl 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 Raw. A malformed or non-file attachment is reachable only through the raw Activity.Attachments list.

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.

FileScopeNotSupportedException

Raised when file bytes are requested for a conversation scope whose download path is not implemented.

Only personal (1:1) uploaded files download directly. groupChat files are surfaced by ListAsync(), but fetching their bytes needs Graph; DownloadAsync()/StreamAsync() throws until that path lands.

FileSource

Where the SDK found an inbound file.

  • BotActivity files come straight from the inbound activity's attachments.
  • Graph files are hydrated through Microsoft Graph.
FileSources

Common file source values.

FileUploadInfo

File upload info for accepted file consent.

FileUrlExpiredException

Raised when an inbound file's short-lived download URL has expired and can no longer fetch bytes.

A personal file's pre-authorized tempauth download URL is valid only briefly. A fetch after it lapses gets a 401/403 from the platform. A handler that downloads once (and does not keep the handle) should not hit this.

Reason distinguishes the two cases; see FileUrlExpiredReason.

GraphCredential

Supplies a bearer token for Graph, and names the identity it belongs to.

Resolved at fetch time rather than stored on the file handle, so a handle stays inert and a token is never acquired before it is needed. Returning null for the token means no credential is available, which surfaces as a FileCredentialException before any request is made.

IncomingFile

A lazy handle to a file attached to the current inbound activity.

Nothing is downloaded until a byte method is called. The handle stays live and holds no memoized bytes, so each of StreamAsync(CancellationToken)/DownloadAsync(CancellationToken)/TextAsync(Encoding, CancellationToken)/SaveAsAsync(String, CancellationToken) fetches afresh. For a personal file that re-fetch is bounded by the short-lived download URL lifetime and may hit its expiry; to read the same file several ways, call DownloadAsync(CancellationToken) once and reuse the returned DownloadedFile.

OpenedFileStream

A freshly opened, single-consumption byte stream plus the metadata resolved while opening it. Owns the underlying HttpResponseMessage; disposing this stream releases the response and connection. Read-only and non-seekable: it hands back the raw response body without leaking the response.

Enums

Name Description
FileActor

The identity a file fetch was attempted as. Reported on FileCredentialException and FileAccessException so a failure names who was refused, not merely that something was.

FileUrlExpiredReason

Distinguishes the two ways an inbound file's short-lived download URL can be found expired.

Delegates

Name Description
FileConsentValueHandler

Delegate for handling file consent invoke activities.