Trigger download directly from link or hyperlink

I have a slice that contains hyperlinks and links to documents, images, and pdfs. Is there any way to download directly from the link? I know I can right-click > save link as or click on the link and then save the file but would prefer a one step process.

Thanks

1 Like

Hello Wenda, welcome to the Prismic community forum!

I'm imagining you want to download these files from your site and not from your repository, is this correct?

If that's the case you can modify the anchor link in your application just by adding a download property to it, that way instead of opening in a new tab, right-clicking, etc..

Hi Paulina,

Yes I want to download the files on my site. I have already reviewed the download property link from w3 but it says chrome only support same-origin download links. The API call for a document give images URL from images.prismic.io and other files URL from prismic.io not from the same-origin. Is there any other way?

You are right, this seems like a roadblock for the download attribute. In that case, you'll need to use the same URL to redirect you and then download the file or use a relative path.

This issue has been closed due to inactivity. Flag to reopen.