5 Easiest Ways To Download File From SharePoint Document Library in Power Apps

In this Power Apps article, I will explain how Power Apps can download a file from a SharePoint Document library.

By using the Download function, we can easily download a SharePoint library file [with extension] in Power Apps. The file may download and open instantly in a new browser tab, or it may save to the downloads folder only, depending on your browser’s settings.

Here, I will tell you some tricky ways to download documents from SharePoint library in Power Apps.

Also, we will discuss how to download files from the SharePoint library folder in Power Apps.

Create a SharePoint Document Library

I have a SharePoint Document Library named Project Documents. This library has various files, such as Excel, Text, PDF, and images [you can upload any files].

Download File From SharePoint Document Library in Power Apps

Power Apps Download File From SharePoint Document Library

These are the four various ways to easily download a file from the SharePoint Document library in Power Apps.

Method – 1: [Use the Copy link option of SharePoint file & Download]

  • Select a file from the SharePoint library -> Click Show more options (…) -> Copy link.
Download SharePoint File in Power Apps
  • In Power Apps, insert a Button control [DOWNLOAD] and set its OnSelect property as:
Download("https://tsinfotechnologies.sharepoint.com/:t:/s/PowerApps/EchzEM7ARqFCrC-qJ3qzZNoBhOud_XldE3b0aYTLGf019g?e=uu0wfo")

OR

Download("https://tsinfotechnologies.sharepoint.com/:t:/s/PowerApps/EchzEM7ARqFCrC-qJ3qzZNoBhOud_XldE3b0aYTLGf019g?e=uu0wfo?web=1")

Where,

  1. “https://tsinfotechnologies.sharepoint.com/:t:/s/PowerApps/EchzEM7ARqFCrC-qJ3qzZNoBhOud_XldE3b0aYTLGf019g?e=uu0wfo” = Paste the link that you have copied from the library file with double quote (“”)
  2. ?web=1 = This helps to open the document in the browser instead of directly downloading
Power Apps Download File From SharePoint Document Library
  • Preview the app and click on the DOWNLOAD button. The specific SharePoint file will open in a new tab, as shown below. Click on Download.
PowerApps Download File From SharePoint Document Library
  • Next, you will be asked to provide a location on your system to save the file. Rename the file (optional) and click on Save.
PowerApps Download File From SharePoint Library

NOTE:

See also  Power Apps Data Table vs Gallery [The Main Differences]

Suppose you have an Excel file in the SharePoint library, and you want this file to be forced downloaded instead of opening in the browser; then you need to append &download=1 including the copied link, i.e.

Download("https://tsinfotechnologies.sharepoint.com/:x:/s/PowerApps/ESnkzgxvBaNAnqvNBKhQcZIBl-NI1HNyDe_BTVWqx04h3Q?e=xlioac&download=1")
Download SharePoint Files in Power Apps

This is the simplest approach to downloading any SharePoint library file in Power Apps.

Method – 2: [Use the SharePoint Source URL & Download]

There is another method that we can use to download the SharePoint library files in Power Apps. Refer to the code below:

Download("https://<site URL>/_layouts/download.aspx?SourceUrl=/sites/<sitename>/<libraryname>/filenamewithfileextension")

In my case, I have used the below one (On Button’s OnSelect property):

Download("https://tsinfotechnologies.sharepoint.com/sites/PowerApps/_layouts/15/download.aspx?SourceUrl=/sites/PowerApps/ProjectDocuments/Invoice-24CCF73B-0006.pdf")
power apps download file from sharepoint library

Preview the app and click DOWNLOAD. It will directly take you to your system to download and ask you to provide the file name. Click Save.

power apps download file from sharepoint list

This is one of the easiest ways to download the SharePoint Document file in Power Apps.

Method – 3: [Use Power Apps Launch Function & Download]

We can download files from the SharePoint document library using the Power Apps Launch function. Refer to the code below:

Launch("https://<DomainName>.sharepoint.com/sites/<SiteName>/_layouts/15/download.aspx?SourceUrl=/sites/<SiteName>/<LibraryName>/<FileNamewithExtension>")

I have used the below formula on Button’s OnSelect property:

Launch("https://tsinfotechnologies.sharepoint.com/sites/PowerApps/_layouts/15/download.aspx?SourceUrl=/sites/PowerApps/ProjectDocuments/Invoice-24CCF73B-0006.pdf")
powerapps download file from sharepoint

In this way, we can download the SharePoint library file in Power Apps.

However, we can’t provide the link manually each time we want to download the specific library file. For this, you can refer to the other method below.

Method – 4: [Use Power Apps Gallery & Download]

Using Power Apps Gallery Control is the ideal way to choose and download the SharePoint library resources you need. Take a look at the gif below.

Power Apps Download Files from SharePoint Document Library

Refer to the steps below to achieve this:

  • Insert a Vertical gallery control and set its Items property as:
Items = 'Project Documents'
Power Apps download SharePoint files
  • Select the Title label of the gallery and set its Text property:
Text = ThisItem.'File name with extension'

This code will give you the SharePoint Document file name with its extension.

Power Apps download SharePoint library files
  • To display the SharePoint library document image, select the image control and set its Image property as:
Image = ThisItem.Thumbnail.Large
Power Apps download SharePoint document library files

Also, you can use the code below:

Image = $"https://static2.sharepointonline.com/files/fabric/assets/item-types/24/{Last(Split(ThisItem.'File name with extension',".")).Value}.svg"

The code that follows first retrieves the file extension before pointing to the correct SharePoint URL.

PowerApps download SharePoint document library files
  • Next, to download the SharePoint file in Power Apps, we need to add a Download icon [Insert -> Icons -> Download] inside the gallery. [Also, remove the next icon button from gallery]
download SharePoint document library files in Power Apps
  • Apply the code below on the Download icon’s OnSelect property as:
OnSelect = Download($"https://tsinfotechnologies.sharepoint.com/sites/PowerApps/_layouts/download.aspx?SourceUrl=https://tsinfotechnologies.sharepoint.com/sites/PowerApps/{ThisItem.'Full Path'}")

Replace your SharePoint domain name and site name.

download SharePoint document library files in PowerApps

This is another approach where user can download the SharePoint document in Power Apps based on their choice.

See also  How to Add All Option in Power Apps Dropdown?

Power Apps Download File From SharePoint Library Folder

In the SharePoint Document library, there is a folder named Financial. Inside it, there is a file named Financial Sheet. Now, in Power Apps, we will download this file from the specific SharePoint library folder.

Download SharePoint files in PowerApps

Refer to the code below:

Download("https://<site URL>/_layouts/download.aspx?SourceUrl=/sites/<sitename>/<libraryname>/<foldername>/filenamewithfileextension")

In my case, I have used the code below:

Download("https://tsinfotechnologies.sharepoint.com/sites/PowerApps/_layouts/15/download.aspx?SourceUrl=/sites/PowerApps/ProjectDocuments/Financial/Financial%20Sheet.xlsx")
Power Apps download files from SharePoint library folder

Preview the app and click DOWNLOAD. Then save the downloaded file and click on Save as like below.

Power Apps Download File From SharePoint Library Folder

This is how we can download the file from the SharePoint library folder in Power Apps.

Some more articles you may also like:

I hope this article helped you a lot. In this tutorial, I have explained four various approaches to downloading the SharePoint document library files in Power Apps.

Also, I have discussed how Power Apps can download files from the SharePoint library folder with a simple example.

>