Stream a file download¶
This operation streams an existing file on disk to the HTTP response as a downloadable attachment, independent of the email-sending functionality in the same class.
| Field | Value |
|---|---|
| Operation ID | OP-CMM-002 |
| Trigger | Call to Utilities.clsMailMessage.StreamDownloadFile(Filename, inPage) |
| Inputs | Virtual filename, hosting AppViewPageBase page |
| Outputs | HTTP response written with file bytes; ends the response |
| Primary components | Utilities.clsMailMessage.StreamDownloadFile |
| Entry point | SAIF.Presentation.Web.Core.Infragistics103\clsMailMessage.vb |
Steps¶
- Maps the virtual path to a physical path (
inPage.Server.MapPath), strips the filename to its last path segment. - Opens a
FileStream, reads the full file into a byte array, closes the stream. - Derives content type from the last 4 characters of the filename — enforces BR-CMM-001:
.txt→text/plain.csv→application/vnd.ms-excel- Any other extension:
sContentTyperemains an empty string. - Sets
Content-Type,content-disposition: attachment; filename=<Filename>(with<Filename>substituted for the actual downloaded file name), andContent-Lengthresponse headers. - Writes the bytes with
BinaryWrite, then callsResponse.End().
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([StreamDownloadFile called]) --> S1[Map virtual path to physical path]
S1 --> S2[Read file into byte array]
S2 --> S3{File extension?}
S3 -->|.txt| S4a[Content-Type = text/plain]
S3 -->|.csv| S4b[Content-Type = application/vnd.ms-excel]
S3 -->|Other| S4c[Content-Type left empty]
S4a --> S5[Set response headers]
S4b --> S5
S4c --> S5
S5 --> S6[BinaryWrite bytes]
S6 --> EndOk([Response.End])
Failure and edge-case behavior¶
- Extensions other than
.txt/.csvare written to the response with noContent-Typeheader value set by this method. - No exception handling is present around file access; a missing or inaccessible file will surface an unhandled exception.
Related documentation¶
Sources¶
- SAIF.Presentation.Web.Core.Infragistics103\clsMailMessage.vb