{"title":"File.DownloadFromStream(InStream, Text, Text, Text, var Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-downloadfromstream-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/file/file-downloadfromstream-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/file/file-downloadfromstream-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Sends a file from server computer to the client computer.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"File.DownloadFromStream(InStream, Text, Text, Text, var Text) Method","slug":"filedownloadfromstreaminstream-text-text-text-var-text-method","at":0,"chars":4750},{"level":2,"title":"Syntax","slug":"syntax","at":334,"chars":218},{"level":2,"title":"Parameters","slug":"parameters","at":552,"chars":1195},{"level":2,"title":"Return Value","slug":"return-value","at":1747,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":1985,"chars":1653},{"level":2,"title":"Example - Cloud","slug":"example---cloud","at":3638,"chars":645},{"level":2,"title":"Example - On-premises","slug":"example---on-premises","at":4283,"chars":335},{"level":2,"title":"Related information","slug":"related-information","at":4618,"chars":132}],"text":"# File.DownloadFromStream(InStream, Text, Text, Text, var Text) Method\n> Version: _Available or changed with runtime version 1.0._\nSends a file from server computer to the client computer. The client computer is the computer that is running the Windows client or the computer that is running the browser that accesses the web client.\n## Syntax\n```al\n[Ok := ]  File.DownloadFromStream(InStream: InStream, DialogTitle: Text, ToFolder: Text, ToFilter: Text, var ToFile: Text)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nInStream\nType: ../instream/instream-data-type\nAn InStream that you want to use to send the data in a file on Business Central Server to a file on the client computer.\nDialogTitle\nType: ../text/text-data-type\nThe title that you want to display in the dialog box for downloading the file. This parameter is not supported by the web client. The title is determined by the end-user's browser.\nToFolder\nType: ../text/text-data-type\nThe default folder in which to save the file to be downloaded. The folder name is displayed in the dialog box for downloading the file. The folder can be changed by the user. This parameter is not supported by the web client. By default, files are saved to the default download location that is configured in the end-user's browser.\nToFilter\nType: ../text/text-data-type\nThe type of file that can be downloaded to the client computer. The type is displayed in the dialog box for downloading the file. This parameter is not supported by the web client.\nToFile\nType: ../text/text-data-type\nThe name to give the downloaded file. This is the default file name that is shown in the dialog box for downloading the file. This value, can be changed by the user.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Remarks\n> NOTE\n> On devices that run Apple iOS, such as iPad, you can only download a file if the Apple iOS device on which you are downloading the file has an application that supports the file type.\nThe business logic runs on the computer that is running Dynamics 365 Business Central service and not on the client. Files are created on a Dynamics 365 service and not locally on the client computer. When you write code, you must consider where files are created.\nUse file-upload-method and file-uploadintostream-string-string-string-text-instream-method to send a file from a client to a Dynamics 365 Business Central service instance.\nUse file-download-method and file-downloadfromstream-method to send a file from a Dynamics 365 Business Central service instance to a client.\nWe recommend that you use the methods in codeunit 419 File Management to upload and download files on-premises.\n> NOTE\n> Internet browsers can only handle one file per request. Therefore, with the Web client, if this method is called in a repetitive statement (or loop) that generates multiple files, only the last file will be sent to the browser. Alternatively, when designing for the Web client, bundle the files in an archive file (.zip), for example, by using the methods found in codeunit 419 File Management. For more details about this design pattern, see Multi-File Download<https://alguidelines.dev/docs/navpatterns/patterns/multi-file-download/>. The methods in codeunit 419 aren't external, therefore can't be used in extensions. Instead, when developing extensions in AL, use the external methods of codeunit 425 Data Compression. The approach is similar.\n## Example - Cloud\n```al\nprocedure DownloadFromCloud()\n    var\n        Data: BigText;\n        ins: InStream;\n        outs: OutStream;\n        TempBLOB: codeunit \"Temp Blob\";\n        filename: Text;\n    begin\n        Data.AddText('Hello World');\n        TempBLOB.CreateOutStream(outs);\n        Data.Write(outs);\n        TempBLOB.CreateInStream(ins);\n        filename := 'helloworld.txt';\n        DownloadFromStream(\n            ins,  // InStream to save\n            '',   // Not used in cloud\n            '',   // Not used in cloud\n            '',   // Not used in cloud\n            filename); // Filename is browser download folder\n    end;\n```\n## Example - On-premises\n```al\n var\n    TempFile: File;\n    NewStream: InsTream;\n    ToFileName: Variant;\nbegin\n    TempFile.CreateTempFile();\n    TempFile.Write('abc');\n    TempFile.CreateInStream(NewStream);\n    ToFileName := 'SampleFile.txt';\n    DownloadFromStream(NewStream,'Export','','All Files (*.*)|*.*',ToFileName);\nend;\n```\n## Related information\nfile-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}