Contentful logo

Contentful Community

Force a download of a linked file

I am trying to force a download of a PDF rather than link to it in the system where they just see it in the browser. Does anyone know how to do this in Contentful? I know there are all kinds of ways to do this but I was hoping there was some simple code I could just add to the URL without having to add a bunch of extra code.

Hi @aimee,

In theory this should force the browser to download the file:

<a href="myfile.pdf" download>Click to Download</a>

However, browsers don’t necessarily respect the download attribute and instead adhere to server’s header information instead.