Breyta

Deila með


Download function

Applies to: Canvas apps Model-driven apps

Downloads a file from the web to the local device.

Description

The Download function downloads a file from the web to the local device.

In native players (Windows, Android, and iOS), the user is prompted for a location to save the file.

When used on the web, Download is dependent on the browser's settings to determine what happens with the file. For images, videos, PDFs, and other file types that the browser natively supports, a new browser tab is opened to display the file. Many browsers support saving the contents to the local file system.

Only on Windows, Download returns the location where the file was stored locally as a text string.

Download can only be used in behavior formulas.

Syntax

Download( Address )

  • Address – Required. The URL address of a web resource to download.

Note

Power Apps cannot authenticate download requests to the address provided in the Download() function.

For example, when using this function to download a file stored on a SharePoint site that requires authentication, the request might work when using a web browser since the browser session might authenticate against the SharePoint site using cached credentials. However, in Power Apps mobile app, the request will not work since authenticating the download request is not handled by the mobile device.

Examples

Simple Download

The following formula will download the user's guide for the Surface Book, a PDF file:

Download( "https://go.microsoft.com/fwlink/?linkid=827480" )

When run in a mobile device, the user will be prompted for a location to save the file.

When run in most web browsers, a new tab will be opened to display the PDF file as most browsers natively support this file type.

Step by Step

The Product Showcase tablet layout template was used for the following example. To create an app with this template, follow the steps from create an app article and select the Product Showcase template. You can also use your own app.

  1. Go to Power Apps.

  2. Select Apps from left navigation pane.

  3. Select your app and then select Edit.

  4. Select Insert from the menu and then select Label.

  5. Move the label to the bottom right of the screen.

  6. From the properties pane on the right-side, select Color as white and set Border thickness at 1.

  7. Select the Text property from right-side and enter text as Download User Guide.

  8. From property list on top left, select OnSelect.

  9. Enter formula as Download("https://go.microsoft.com/fwlink/?linkid=827480"). You can also use any other URL of your choice.

    Download example.

  10. Save and publish the app.

  11. Play the app.

  12. Select the Download User Guide button to download the guide.

Note

Your browser settings determine whether to download the file or open the file directly in a new tab. For more details, go to Download function description.

See also

Canvas app formula reference