In this blog, we will learn how to create a download link for documents uploaded in SharePoint library. We had a requirement to add links to documents (uploaded in SharePoint library) on SharePoint pages to be able to download the files on click of link using OOTB features only.
There are 2 options for creating file download link for MS Office files & PDF files.
Option 1: Using "Copy link" option in SharePoint
Step 1. Select your document in SharePoint library and click on "Copy link" option
Step 2. Click on "Copy"
Step 3. Use copied link and append "&download=1" at the end
Example:
https://qhdm.sharepoint.com/:b:/s/MyDemoSite/EceQyIrHYC1IhkHNXr1y43oB3IvHGlU_snYAw55H3KHzKw?e=dQGPUd&download=1
Option 2: Using "download.aspx" page
Step 1. Select file in SharePoint library and open the details pane
Step 2. Copy direct path from more details section of details pane
Step 3. Prepare a new link as per the below format using your tenant, sitename and file direct path copied in previous step
https://<tenant>.sharepoint.com/sites/<sitename>/_layouts/15/download.aspx?SourceUrl=<filepath>
Example: https://qhdm.sharepoint.com/sites/MyDemoSite/_layouts/download.aspx?SourceUrl=https://qhdm.sharepoint.com/sites/MyDemoSite/Shared%20Documents/TESTFile.docx
Step 4. Embed links in SharePoint page using OOTB webparts(Text, Button, etc)
Thanks for reading!