Skip to main content
Post

#PowerPlatformTip 159: 'Force a Direct File Download in Power Apps with Launch'

#PowerPlatformTip 159: 'Force a Direct File Download in Power Apps with Launch'

TL;DR: Launch(FileURL & "&download=1") (or "?download=1" when the URL has no query string yet, step 3 picks the separator for you) may download a SharePoint file instead of opening a preview, but download=1 is undocumented and not guaranteed. The documented Power Fx alternative is Download().

Opening a document from a canvas app with Launch() normally hands the URL to the browser, which may show a preview of the PDF, image or Office file. Appending &download=1 to a SharePoint URL is an undocumented community convention; SharePoint may ignore it in some contexts.

💡 Challenge

You store files in SharePoint and surface their links in a gallery or button. Calling Launch(ThisItem.FileURL) opens the file in the browser’s built-in viewer (preview mode). For a quick look that’s fine, but when users actually need the file on their device, the extra “download from the viewer” step is annoying and, on mobile, sometimes impossible.

✅ Solution

download=1 is a SharePoint URL parameter (not a Power Fx feature) that many makers use to make SharePoint respond with Content-Disposition: attachment, which forces the browser to download the file instead of rendering it. Because Launch() simply appends parameters to the query string, you can add it right in the formula.

⚠️ Reality check: download=1 is an undocumented SharePoint URL behavior and isn’t guaranteed; modern SharePoint may rewrite or ignore it in some contexts. The documented Power Fx Download() function is an alternative, with behavior that depends on the player and URL.

🔧 How It’s Done

1. Get the file URL from your data source.

🔸 In a SharePoint document library, the file’s absolute URL (FileRef-based) works, for example:

1
https://contoso.sharepoint.com/sites/Team/Shared Documents/Report.pdf

2. Append the download parameter inside Launch. Use the conventional lowercase download=1.

🔸 If the URL already has a query string (contains ?), add &download=1:

Launch( ThisItem.FileURL & "&download=1" )

🔸 If the raw URL has no ? yet, start the query string with ?download=1 instead:

Launch( ThisItem.FileURL & "?download=1" )

3. Make it robust for both cases so you don’t have to guess:

Launch(
    ThisItem.FileURL &
    If( "?" in ThisItem.FileURL, "&", "?" ) &
    "download=1"
)

🔸 This checks whether a ? is already present and picks & or ? automatically. Don’t test with IsMatch( ThisItem.FileURL, "\?" ): in Power Apps IsMatch matches the entire text by default (MatchOptions.Complete), so it would only be true for a text that consists of nothing but a ? and the parameter would always get a ?.

🔸 The parameter must come before a URL fragment (#...). Behind a # the browser never sends it to SharePoint, so remove the fragment from the URL first if there is one.

4. Put it on a button or gallery item OnSelect. Where the parameter is honored, the file downloads immediately on the web; in the mobile player the user is prompted to save it.

🔸 Allow pop-ups if your app is embedded (Teams, SharePoint, Power BI), otherwise the browser may block the new window that Launch() opens.

🎉 Result

Where SharePoint honors the parameter, a single click saves the file to the user’s device instead of opening a preview they then have to download manually. No Power Automate flow, no custom connector, no extra component - just one parameter on the URL.

🌟 Key Advantages

🔸 One-liner: no flow, no premium connector, no component to import.

🔸 Real download (when honored): SharePoint returns the file as an attachment via Content-Disposition, so browsers save instead of preview.

🔸 Works with what you have: any absolute SharePoint file URL (without a fragment) already in your gallery or list.

🛠️ FAQ

1. Is download=1 an official, guaranteed feature?

No. It’s an undocumented SharePoint URL behavior, not a Power Apps / Launch() feature. Launch() only appends it to the query string; SharePoint decides what to do. Modern SharePoint may rewrite or ignore download=1 in some contexts, so treat it as best-effort. Microsoft documents the Power Fx Download() function as an alternative.

2. What’s the difference to the native Download() function?

Download(Address) is a documented Power Fx function that downloads a file to the device. In native players (Windows/Android/iOS) the user is prompted for a save location, but in the browser its behavior depends on browser settings - PDFs, images and videos often just open in a new tab. Per Microsoft, Download() also can’t authenticate protected SharePoint links in the mobile player. So Download() is the officially supported route, while &download=1 is an unofficial trick that can force a save more reliably for library files where it’s honored.

3. The file still opens in a preview - what’s wrong?

First, remember download=1 isn’t guaranteed. Then check that you appended it with the correct separator (? for the first parameter, & afterwards, lowercase) and that the link is a direct file URL. Some sharing links open a viewer page rather than the file; use the file’s absolute path (FileRef) instead. If it’s simply being ignored by your tenant, fall back to Download() where it works for your client (not for protected SharePoint links in the mobile player, see question 2), a document library web part, or a Power Automate flow that streams the file.

4. Does the user need permission to the file?

Yes. The download runs in the user’s browser session, so they must have at least read access to the file in SharePoint, just like opening it normally.

Build your own business apps. The Power Apps course at the Power Platform Academy takes you from the first canvas app to a finished solution in 4 weeks, live online. Prefer a quick start? The free live workshops take 30 to 45 minutes.

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy, which runs free live workshops (in German). See the next free workshop dates (in German). For companies that want this implemented for them, see KMUpower: Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.