# Trigger Download from Link?

**URL:** <https://community.glideapps.com/t/trigger-download-from-link/77479>\
**Category:** Ask for Help\
**Created:** [October 30, 2024, 3:14pm UTC](https://community.glideapps.com/t/trigger-download-from-link/77479 "2024-10-30T15:14:28Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/curtis/32/59826_2.png) [@Curtis](https://community.glideapps.com/u/Curtis)\
**Post date:** [October 30, 2024, 3:14pm UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/1 "2024-10-30T15:14:28Z")

</div>

Is it possible to trigger a document (PDF) download from a link.  
As the files are stored in Google storage I’m hoping theres a link parameter which can be applied through a template column.

Found this on a forum but unsure how to implement:  
“[https://storage.googleapis.com/{bucket.name}/{blob.name}](https://storage.googleapis.com/%7Bbucket.name%7D/%7Bblob.name%7D)”

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [October 30, 2024, 3:43pm UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/2 "2024-10-30T15:43:55Z")

</div>

You can put the link in a basic text column and set a button action to open link.

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [October 30, 2024, 3:45pm UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/3 "2024-10-30T15:45:13Z")

</div>

Additionally, you can make you template in a computed template column with the format you have if you want to set parameters from other columns or related data.

---

<div class="post-metadata">

**Author:** ![Curtis](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/curtis/32/59826_2.png) [@Curtis](https://community.glideapps.com/u/Curtis)\
**Post date:** [October 30, 2024, 4:11pm UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/4 "2024-10-30T16:11:01Z")

</div>

Thanks Maxime,  
Yes I’m looking specifically at implementing an open url action which triggers download of a PDF file without the user needing to take any further actions.

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [October 30, 2024, 4:14pm UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/5 "2024-10-30T16:14:40Z")

</div>

I don’t think that this is possible out of the box. But, you might try creating a custom AI Component and asking to trigger an action on load. I am pretty sure that would work! ✨

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [October 31, 2024, 6:53pm UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/6 "2024-10-31T18:53:42Z")

</div>

I attempted to create a prompt that allows the AI component to perform an action on load after a delay of 100 ms. While I couldn’t get it to work with the provided delay value, it still enables us to make the AI execute a custom action upon page load.

Here is the prompt :

```auto
1. In the **DATA** section, define only the `Delay` property with a milliseconds value.
2. On component load, automatically retrieve the `Delay` property. If the property is not set, use a default value of 100 milliseconds.
3. Use the retrieved `Delay` property to start a `setTimeout` function.
4. After the specified delay:  
   a. Dispatch the **Show Notification** action from the **action** section.
5. The **Show Notification** action must be defined in the **action** section.
6. There will be no visual elements, start, or stop button; the action will trigger automatically without any manual intervention.
7. Ensure that all code runs within the component's secure context to avoid violations of Content Security Policy (CSP) and prevent loading external scripts.

```

And this is what it looks like :

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/6/a6f562703b1f4f588aed0e092d11b36203d27293.png)  
or you could use a helper table :  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/3/632c5ff7d10abc86a635f21a5323caca006ad535.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/6/46a6a1d0e794c32a9d54518213013825319f4501.png) or

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/5/f5ae193b54d293865d43193451687c54cff8aad7.png)

Here’s a demo for you :  
 ![msedge_pVMGsMxG0c-ezgif.com-video-to-gif-converter](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/0/605ff05678a3f65b068ade8564bf521d29d4dc8b.gif)

_My related post : [Auto Action trigger](https://community.glideapps.com/t/auto-action-trigger/77525)_

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [November 1, 2024, 12:07am UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/7 "2024-11-01T00:07:51Z")

</div>

This still only opens the file in a new tab and not exactly “downloading” it, right?

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [November 1, 2024, 12:10am UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/8 "2024-11-01T00:10:06Z")

</div>

If you put the link of the CSV, your browser will trigger the download automatically. I set a gif link, that is why the browser showed it instead of downloading it. Using the CSV should work the way you want. Try it and tell me if it works!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [November 1, 2024, 12:11am UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/9 "2024-11-01T00:11:57Z")

</div>

Ah yes, CSV works, I was thinking PDFs.

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [November 1, 2024, 12:15am UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/10 "2024-11-01T00:15:13Z")

</div>

The way files are displayed depends on your browser settings. By default, most browsers open PDFs directly in the browser using a built-in viewer, but this can vary based on your browser’s configuration and any installed extensions that offer alternative viewers. Similarly, XML files may display as plain text in the browser, while Excel files often prompt for download or may open in an external application, depending on the browser’s compatibility settings and any extensions you have.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [November 1, 2024, 12:17am UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/11 "2024-11-01T00:17:11Z")

</div>

In my experience, Excel files always download on click, same as Word files. CSVs downloads on Chromium browsers, but not Safari (displayed as text). PDFs never get downloaded.

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [November 1, 2024, 12:22am UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/12 "2024-11-01T00:22:19Z")

</div>

That extension will change the behaviour when clicking on Excel files :

> **[Office Editing for Docs, Sheets & Slides - Chrome Web Store](https://chromewebstore.google.com/detail/office-editing-for-docs-s/gbkeegbaiigmenfmjfclcdgdpimamgkj)**
>
> View and edit Microsoft Word, Excel, and PowerPoint files with Google Docs, Sheets, and Slides

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [November 1, 2024, 12:23am UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/13 "2024-11-01T00:23:53Z")

</div>

Also that one would open PDF in a Adobe PDF viewer instead of the built-in viewer. [https://chromewebstore.google.com/detail/adobe-acrobat-outils-de-m/efaidnbmnnnibpcajpcglclefindmkaj?mv=acomacrobat](https://chromewebstore.google.com/detail/adobe-acrobat-outils-de-m/efaidnbmnnnibpcajpcglclefindmkaj?mv=acomacrobat)

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [November 1, 2024, 1:18am UTC](https://community.glideapps.com/t/trigger-download-from-link/77479/14 "2024-11-01T01:18:27Z")

</div>

@Curtis To answer your question I don’t think it is possible with the current configuration of glide. Except if someone find a better answer than me, here are the things that I’ve tried:

I know that in HTML, if you set an url on a \<a\> tag and add the “download” attribute, it would trigger a download.

Alternatively, you might want to add this script in a JavaScript Column:

```javascript
// The following code should run as-is; do not add any other code or modifications
// Note: For CORS restrictions, ensure that the server at 'url' allows CORS requests.

const downloadFile = (url, filename = '') => { 
  if (filename.length === 0) filename = url.split('/').pop(); 
  const req = new XMLHttpRequest(); 
  req.open('GET', url, true); 
  req.responseType = 'blob'; 
  req.onload = function () { 
    const blob = new Blob([req.response], { type: 'application/pdf' }); 
    const isIE = false || !!document.documentMode; 
    if (isIE) { 
      window.navigator.msSaveBlob(blob, filename); 
    } else { 
      const windowUrl = window.URL || window.webkitURL; 
      const href = windowUrl.createObjectURL(blob); 
      const a = document.createElement('a'); 
      a.setAttribute('download', filename); 
      a.setAttribute('href', href); 
      document.body.appendChild(a); 
      a.click(); 
      document.body.removeChild(a); 
    } 
  }; 
  req.onerror = function() {
    console.error("Download failed due to CORS policy.");
  };
  req.send(); 
}; 

downloadFile(p1);

```

Set p1 to the PDF url column.

It should looks like this:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/1/a1f6355cf871e43a87d7e0c80e2501eab5188871.png)

Then, you can add a Text Component linked to that JavaScript column as the content.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/2/22cdc0b589c609b9bfcb76c3794bad22096d7c2f.png)

_This assumes CORS is enabled._ Meaning that the domain of the file URL must be the same as your app URL.

Else, you will still hit a wall with that error :  
 ![Download is disallowed. The frame initiating or instantiating the download is sandboxed, but the flag ‘allow-downloads’ is not set. See https://www.chromestatus.com/feature/5706745674465280 for more details.](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/c/9c8f173d4d0e7c1ae7e6044bd9ec9ac1c2b1192e.png)
