Tutorials/Power Apps/SharePoint Document Downloads in Power Apps: The Force Download Trick
Power Appsintermediate

SharePoint Document Downloads in Power Apps: The Force Download Trick

Save files from a SharePoint document library straight to the user’s device without opening in the browser using a simple URL tweak in Power Apps.

NA
Narmer Abader
@narmer · Published June 3, 2026

When you need to give app users a one‑click way to pull a file from a SharePoint document library onto their computer, the built-in Download function often opens the file in a browser tab instead of saving it directly to the Downloads folder. This article shows a small but effective workaround: using SharePoint’s own download.aspx endpoint to force the browser to download the file. You’ll build a gallery that lists documents and lets users download any file with a single press.

A law firm wants its paralegals to quickly access signed contracts stored in SharePoint. The app should show a list of documents, display the correct file type icon, and allow a direct download to the paralegal’s device. We’ll walk through creating this app from scratch, using a SharePoint document library named Legal Documents.

Prerequisites

  • A SharePoint document library with at least a few documents uploaded (any type – PDF, DOCX, XLSX, etc.).
  • A Power Apps environment with a blank canvas app.
  • User accounts that have at least Read access to the library.

Step 1 – Connect the SharePoint Library to the App

In Power Apps Studio, create a new blank app. Add a Vertical gallery (or any list control) to the screen. Open the Items property of the gallery and connect to your SharePoint library.

powerfxGallery Items property
'Legal Documents'

After the connection is made, the gallery automatically includes the columns you need: 'File name with extension' and 'Full Path'.

Step 2 – Show the File Name and a File Type Icon

You want to display the file name next to an icon that indicates the file type (PDF, Word, Excel, etc.). Set the gallery layout to Image and Title if you prefer, or adjust manually.

Label for file name

Select the label inside the gallery and set its Text property:

powerfxLabel Text property
ThisItem.'File name with extension'

Image for file icon

SharePoint provides a CDN that serves SVG icons for every known file extension. Use the Image property of an image control (or the gallery’s image element) with this formula:

powerfxImage property for file icon
"https://static2.sharepointonline.com/files/fabric/assets/item-types/24/" & Last(Split(ThisItem.'File name with extension', ".")).Value & ".svg"

This extracts the extension from the file name and builds the URL to match the appropriate icon.

Step 3 – Add a Download Button

Replace the default gallery icon (often a right arrow) with a Download icon. Select the icon and change its Icon property:

powerfxButton Icon property
Icon.Download

Give it a distinct color so it stands out:

  • Color: Color.Black
  • Fill: Color.LightBlue

Step 4 – The Force Download Trick

The standard Download function calls the raw file URL, which often prompts the browser to display the file inline (especially for PDFs). To force a save‑to‑disk action, use SharePoint’s download.aspx page. This endpoint sends the correct Content-Disposition: attachment header that tells the browser to download rather than open.

In the OnSelect property of your download icon, place this call:

powerfxOnSelect of the download icon
Download("https://yourtenant.sharepoint.com/sites/LegalDocuments/_layouts/download.aspx" & "?SourceUrl=https://yourtenant.sharepoint.com/sites/LegalDocuments/" & ThisItem.'Full Path')

Important: Replace https://yourtenant.sharepoint.com/sites/LegalDocuments with the actual root URL of your SharePoint site. You can find this by opening the library in a browser and copying the URL up to the document library name (but including the site part).

The 'Full Path' field contains the full server‑relative path of the file (including the library name, subfolders, and file name). By appending it to the SourceUrl parameter, the download.aspx page knows exactly which file to serve.

Step 5 – Test the Experience

Preview the app and press the download icon. In modern browsers (Edge, Chrome, Firefox) the file should appear in the download notification area and then be saved to your default Downloads folder. Files that were previously opened in a new tab (like PDFs) will now be downloaded directly.

Security and Performance Considerations

  • The Download function still respects SharePoint permissions. Users must have at least Read access to the document library; otherwise the download.aspx call will fail.
  • No delegation issues exist with this pattern because you are only reading the file metadata from the gallery and then calling Download with the constructed URL.
  • For large files, the download time depends on the file size and the user’s network. SharePoint streaming limits still apply.

Common Mistakes and Troubleshooting

IssueLikely CauseFix
File opens in browser instead of downloadingUsing the direct file URL instead of download.aspxMake sure the URL begins with .../_layouts/download.aspx?SourceUrl=...
“Access denied” errorUser lacks permissions on the SharePoint libraryVerify the user’s role; grant at least Read access
Icon shows as broken imageThe extension is not recognised by the SharePoint CDNThe icon CDN covers most common types. For unusual extensions, provide a fallback static image
Gallery shows no filesLibrary name is misspelled or connection not establishedRe‑create the data source using the exact library name

Recommendations

  • Always use the download.aspx URL when you want a true save‑to‑disk experience. Do not rely solely on the Download function with a plain file URL.
  • Consider storing the SharePoint site root URL in a global variable or a custom environment variable so you can reuse it across multiple screens.
  • If your library uses versioning, the 'Full Path' field points to the current (major) version. To download a specific version, append &VersionId=<ID> to the SourceUrl.

References