Trigger Download from Link?

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}

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

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.

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.

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! :sparkles:

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 :

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 :


or you could use a helper table :

or

Here’s a demo for you :
msedge_pVMGsMxG0c-ezgif.com-video-to-gif-converter

My related post : Auto Action trigger

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

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!

1 Like

Ah yes, CSV works, I was thinking PDFs.

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.

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.

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

1 Like

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

@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:

// 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:

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

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.