For some reason when trying to download a file, it fails. I've tried few different ways, all of them failed. Than I read something about pdf/word files are "forbidden" in Gatsby ??!
The default <a href="route-to-file" download></a>
doesn't seem to work, it shows failed to download. Any help is appreciated!
If you are using a local image, copy it into the project. A folder such as src/images is a good choice. Add the StaticImage component to your template.
Gatsby Cloud is a cloud platform specifically built for building, previewing, and deploying Gatsby websites. Your site is built & deployed in real-time on a global Edge network that provides millisecond load times for site visitors around the world.
See Importing Assets Directly Into Files and Using the Static Folder
import React from "react"
import downloadFile from '../downloads/file.pdf'
const IndexPage = () => (
<>
<a href={downloadFile} download>Download the directly imported file</a>{` `}
<a href={`download.pdf`} download>Download the file that is already in your static folder</a>
</>
)
export default IndexPage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With